-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathindex.html
More file actions
2501 lines (2044 loc) · 154 KB
/
index.html
File metadata and controls
2501 lines (2044 loc) · 154 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html SYSTEM 'about:legacy-compat'>
<html><head><title>DNS API Description</title>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<style type="text/css">
<!--
div.forh { white-space: pre; font-family: monospace; margin-top: 0; margin-bottom: 0 }
h1 { font-size: 18pt; }
h2 { font-size: 14pt; }
p { margin-bottom: 0 }
p.title { font-size: 24pt; font-weight: bold; margin-top: 0; margin-bottom: 0; text-align: center; }
p.title2 { font-size: 12pt; margin-top: 0; text-align: center; }
p.define { font-family: monospace; font-weight: bold; margin-bottom: 0; margin-left: 2em; }
p.descrip { margin-left: 4em; margin-top: 0; }
p.cont { margin-top: 0 }
p.bull { margin-top: 0; margin-bottom: 0 }
p.bull:before { content: "• " }
pre { margin-bottom: 0 }
table { border-spacing: 8pt }
td, th { vertical-align: top; text-align: left }
td.num { font-weight: bold; width: 2em }
tr.code { font-family: monospace }
.done { background: lightgreen }
.wontdo { background: lightpink }
.moved { background: lightskyblue }
.default { font-weight: bold }
/* The following is for Pygments-highlighted code */
.highlight .hll { background-color: #ffffcc }
.highlight { background: #ffffff; }
.highlight .c { color: #408080; font-style: italic } /* Comment */
.highlight .err { border: 1px solid #FF0000 } /* Error */
.highlight .k { color: #008000; font-weight: bold } /* Keyword */
.highlight .o { color: #666666 } /* Operator */
.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #BC7A00 } /* Comment.Preproc */
.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */
.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #FF0000 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #00A000 } /* Generic.Inserted */
.highlight .go { color: #808080 } /* Generic.Output */
.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #0040D0 } /* Generic.Traceback */
.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008000 } /* Keyword.Pseudo */
.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #B00040 } /* Keyword.Type */
.highlight .m { color: #666666 } /* Literal.Number */
.highlight .s { color: #BA2121 } /* Literal.String */
.highlight .na { color: #7D9029 } /* Name.Attribute */
.highlight .nb { color: #008000 } /* Name.Builtin */
.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.highlight .no { color: #880000 } /* Name.Constant */
.highlight .nd { color: #AA22FF } /* Name.Decorator */
.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */
.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0000FF } /* Name.Function */
.highlight .nl { color: #A0A000 } /* Name.Label */
.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #19177C } /* Name.Variable */
.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mf { color: #666666 } /* Literal.Number.Float */
.highlight .mh { color: #666666 } /* Literal.Number.Hex */
.highlight .mi { color: #666666 } /* Literal.Number.Integer */
.highlight .mo { color: #666666 } /* Literal.Number.Oct */
.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
.highlight .sc { color: #BA2121 } /* Literal.String.Char */
.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #BA2121 } /* Literal.String.Double */
.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */
.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.highlight .sx { color: #008000 } /* Literal.String.Other */
.highlight .sr { color: #BB6688 } /* Literal.String.Regex */
.highlight .s1 { color: #BA2121 } /* Literal.String.Single */
.highlight .ss { color: #19177C } /* Literal.String.Symbol */
.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
.highlight .vc { color: #19177C } /* Name.Variable.Class */
.highlight .vg { color: #19177C } /* Name.Variable.Global */
.highlight .vi { color: #19177C } /* Name.Variable.Instance */
.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */-->
</style>
</head><body>
<p class=title>Description of the <code>getdns</code> API</p>
<p class=title2>Originally edited by Paul Hoffman</p>
<p class=title2>Currently maintained by the <a
href="mailto:team@getdnsapi.net">getdns team</a></p>
<p class=title2>Document version: "getdns December 2015"</p>
<p>This document describes a modern asynchronous DNS API. This new API is intended to be useful to
application developers and operating system distributors as a way of making
all types of DNS information easily available in many types of programs. The major features
of this new API are:</p>
<ul>
<li>Full support for event-driven programming</li>
<li>Supports DNSSEC in multiple ways</li>
<li>Mirroring of the resolution in <code>getaddrinfo()</code></li>
<li>Easily supports all RRtypes, even those yet to be defined</li>
</ul>
<p>There is more background into the design and future goals of this API
<a href="#Commentary">later in this document</a>.</p>
<p>This document was discussed on the <a href="http://www.vpnc.org/mailman/listinfo/getdns-api">
getdns-api mailing list</a>; future versions of the API might be discussed there as well.
(If you
want to contact the editors off-list, please send mail to <a
href="mailto:team@getdnsapi.net">team@getdnsapi.net</a>.)</p>
<h1>1. The <code>getdns</code> Async Functions</h1>
<p>The API has four async functions:</p>
<ul>
<li><code>getdns_address</code> for doing <code>getaddrinfo()</code>-like address lookups</li>
<li><code>getdns_hostname</code> for doing <code>getnameinfo()</code>-like name lookups</li>
<li><code>getdns_service</code> for getting results from SRV lookups</li>
<li><code>getdns_general</code> for looking up any type of DNS record</li>
</ul>
<h2>1.1 <code>getdns_general()</code></h2>
<div class=forh id="getdnsfuncgeneral">getdns_return_t
getdns_general(
getdns_context *context,
const char *name,
uint16_t request_type,
getdns_dict *extensions,
void *userarg,
getdns_transaction_t *transaction_id,
getdns_callback_t callbackfn
);
</div>
<p class=define><code><b>context</b></code></p>
<p class=descrip>A pointer to the DNS context that is to be used with this call. DNS contexts are
described <a href="#Contexts">later in this document</a>. Note that a context <i>must</i> be created
before calling the function.</p>
<p class=define><code><b>*name</b></code></p>
<p class=descrip>This is a null-terminted string consisting of an
ASCII-based domain name to be looked up.
The values here follow the rules in section 2.1 of RFC 4343
to allow non-ASCII octets and special characters in labels.</p>
<p class=define><code><b>request_type</b></code></p>
<p class=descrip>Specifies the RRtype for the query; the RRtype numbers are listed in the IANA
registry. For example, to get the NS records, <code>request_type</code> would be 2. The API also has
defined macros for most of the RRtypes by name; the definition names all start with
"<code>GETDNS_RRTYPE_</code>". For example, to get the NS records, you can also set the
<code>request_type</code> to <code>GETDNS_RRTYPE_NS</code>.
(The full list of request types is always
<a href="https://www.iana.org/assignments/dns-parameters/dns-parameters.xml">here</a>.)</p>
<p class=define><code><b>*extensions</b></code></p>
<p class=descrip>Specifies the extensions for this request; the value may be NULL if there are no
extensions. See <a href="#Extensions">the section below</a> for information on how to specify
the extensions used for a request.</p>
<p class=define><code><b>*userarg</b></code></p>
<p class=descrip>A void* that is passed to the function, which the function
returns to the callback function untouched. <code>userarg</code> can be used by the callback
function for any user-specific data needed. This can be NULL.</p>
<p class=define><code><b>*transaction_id</b></code></p>
<p class=descrip>A pointer to a value that is filled in by the
function to identify the callback being made.
This pointer can be NULL, in which case it is ignored and no value is assigned.
The <code>getdns_cancel_callback()</code> function uses the
<code>transaction_id</code> to determine which callback is to be cancelled.
If the function fails,
<code>transaction_id</code> is set to 0.</p>
<p class=define><code><b>*callbackfn</b></code></p>
<p class=descrip>A pointer to a callback function that is defined by the application.
Typically, the callback function will do all the processing on the results from
the API. The parameters of the callback are defined below. This really needs
to be a pointer to a function (and not something like NULL); otherwise, the
results are unpredictable.</p>
<p>The async <code>getdns</code> functions return <code>GETDNS_RETURN_GOOD</code> if the call was properly formatted.
It returns <code>GETDNS_RETURN_BAD_DOMAIN_NAME</code> if the API determines that the name passed to
the function was bad, <code>GETDNS_RETURN_BAD_CONTEXT</code> if the context has internal deficiencies,
<code>GETDNS_RETURN_NO_SUCH_EXTENSION</code> if one or more extensions do not exist, or
<code>GETDNS_RETURN_EXTENSION_MISFORMAT</code> if the contents of one or more of the
extensions is incorrect. All of the return values are given <a
href="#ReturnCodes">later in this document</a>.</p>
<h2>1.2 <code>getdns_address()</code></h2>
<div class=forh id="getdnsfuncaddress">getdns_return_t
getdns_address(
getdns_context *context,
const char *name,
getdns_dict *extensions,
void *userarg,
getdns_transaction_t *transaction_id,
getdns_callback_t callbackfn
);
</div>
<p>There are three critical differences between <code>getdns_address()</code> and
<code>getdns_general()</code> beyond the missing <code>request_type</code> argument:</p>
<ul>
<li>In <code>getdns_address()</code>, the <code>name</code> argument can only take a host name.</li>
<li>You do not need to include a <code>return_both_v4_and_v6</code> extension with the call in
<code>getdns_address()</code>: it will always return both IPv4 and IPv6 addresses.</li>
<li><code>getdns_address()</code> always uses all of namespaces from the context (to better emulate
<code>getaddrinfo()</code>), while <code>getdns_general()</code> only uses the DNS namespace.</li>
</ul>
<h2>1.3 <code>getdns_hostname()</code></h2>
<div class=forh id="getdnsfunchostname">getdns_return_t
getdns_hostname(
getdns_context *context,
getdns_dict *address,
getdns_dict *extensions,
void *userarg,
getdns_transaction_t *transaction_id,
getdns_callback_t callbackfn
);
</div>
<p>The address is given as a <code>getdns_dict</code> data structure (defined below). The list must
have two names: <code>address_type</code> (whose value is a bindata; it is currently either "IPv4"
or "IPv6" (which are case-sensitive)) and <code>address_data</code> (whose value is a bindata).</p>
<h2>1.4 <code>getdns_service()</code></h2>
<div class=forh id="getdnsfuncservice">getdns_return_t
getdns_service(
getdns_context *context,
const char *name,
getdns_dict *extensions,
void *userarg,
getdns_transaction_t *transaction_id,
getdns_callback_t callbackfn
);
</div>
<p><code>name</code> must be a domain name for an SRV lookup; the call returns the
relevant SRV information for the name.</p>
<h2>1.5 Callback Functions for <code>getdns</code></h2>
<p>A call to the async <code>getdns</code> functions typically returns before any network or file I/O occurs. After
the API marshalls all the needed information, it calls the callback function that was passed by the
application. The callback function might be called at any time, even before the calling function
has returned. The API guarantees that the callback will be called exactly once unless the calling function
returned an error, in which case the callback function is never called.<p>
<p>The <code>getdns</code> calling function calls the callback with the parameters defined
as follows:</p>
<div class=forh id="getdns_callback_t">
typedef void (*getdns_callback_t)(
getdns_context *context,
getdns_callback_type_t callback_type,
getdns_dict *response,
void *userarg,
getdns_transaction_t transaction_id);
</div>
<p class=define><code><b>context</b></code></p>
<p class=descrip>The DNS context that was used in the calling function. See <a
href="#ContextInitial">below</a> for a description of the basic use of contexts, and <a
href="#Contexts">later</a> for more advanced use.</p>
<p class=define><code><b>callback_type</b></code></p>
<p class=descrip>Supplies the reason for the callback. See below for the codes and reasons.</p>
<p class=define><code><b>*response</b></code></p>
<p class=descrip>A response object with the response data.
This is described below.
The application is responsible for cleaning up the response object with getdns_dict_destroy.</p>
<p class=define><code><b>*userarg</b></code></p>
<p class=descrip>Identical to the <code>*userarg</code> passed to the calling function.</p>
<p class=define><code><b>transaction_id</b></code></p>
<p class=descrip>The transaction identifier that was assigned by the calling function.</p>
<p>The following are the values for callback_type.</p>
<p class=define>GETDNS_CALLBACK_COMPLETE</p>
<p class=descrip>The response has the requested data in it</p>
<p class=define>GETDNS_CALLBACK_CANCEL</p>
<p class=descrip>The calling program cancelled the callback; response is NULL</p>
<p class=define>GETDNS_CALLBACK_TIMEOUT</p>
<p class=descrip>The requested action timed out; response is filled in with empty structures</p>
<p class=define>GETDNS_CALLBACK_ERROR</p>
<p class=descrip>The requested action had an error; response is NULL</p>
<h2>1.6 <a id="ContextInitial">Setting Up The DNS Context</a></h2>
<p>Calls to <code>getdns</code> functions require a DNS context, which is a group of API settings
that affect how DNS calls are made. For most applications, a default context is sufficient.</p>
<p>To create a new DNS context, use the function:</p>
<div class=forh>getdns_return_t
getdns_context_create(
getdns_context **context,
int set_from_os
);
</div>
<p class=cont>The call to <code>getdns_context_create</code> immediately returns a context that can
be used with other API calls; that context contains the API's default values. Most applications will
want <code>set_from_os</code> set to <code>1</code>.</p>
<div class=forh>getdns_return_t
getdns_context_create_with_memory_functions(
getdns_context **context,
int set_from_os,
void *(*malloc)(size_t),
void *(*realloc)(void *, size_t),
void (*free)(void *)
);
getdns_return_t
getdns_context_create_with_extended_memory_functions(
getdns_context **context,
int set_from_os,
void *userarg,
void *(*malloc)(void *userarg, size_t),
void *(*realloc)(void *userarg, void *, size_t),
void (*free)(void *userarg, void *)
);
</div>
<p>To clean up the context, including cleaning up all outstanding transactions that were called
using this context, use the function:</p>
<div class=forh>void
getdns_context_destroy(
getdns_context *context
);
</div>
<p class=cont>When <code>getdns_context_destroy()</code> returns, the
application knows that all outstanding transactions associated with this
context will have been called; callbacks that had not been called before
<code>getdns_context_destroy()</code> was called will be called with a callback_type of
<code>GETDNS_CALLBACK_CANCEL</code>. <code>getdns_context_destroy()</code> returns after
all of the needed cleanup is done and callbacks are made.</p>
<h2>1.7 Canceling a Callback</h2>
<p>To cancel an outstanding callback, use the following function.</p>
<div class=forh>getdns_return_t
getdns_cancel_callback(
getdns_context *context,
getdns_transaction_t transaction_id
);
</div>
<p class=cont>This causes the API to call the callback with a <code>callback_type</code> of
<code>GETDNS_CALLBACK_CANCEL</code> if the callback for this <code>transaction_id</code> has not
already been called. This will cancel the callback regardless of what the original call was
doing (such as in the middle of a DNS request, while DNSSEC validation is happening, and so on).
The callback code for cancellation should clean up any memory related to the
identified call, such as to deallocate the memory for the userarg.
<code>getdns_cancel_callback()</code> may return immediately, even before the callback finishes its
work and returns. Calling <code>getdns_cancel_callback()</code> with a <code>transaction_id</code>
of a callback that has already been called or an unknown <code>transaction_id</code> returns
<code>GETDNS_RETURN_UNKNOWN_TRANSACTION</code>; otherwise, <code>getdns_cancel_callback()</code>
returns <code>GETDNS_RETURN_GOOD</code>.</p>
<h2>1.8 Event-driven Programs</h2>
<p>Event-driven programs (sometimes called "async programs") require an event
base and event loop (among other things). Different event libraries have
different structures or the event base. Because of this, there is no standard
method to set the event base in the DNS API: those are all added as
extensions. The API is distributed as a core package and one or more sets of
extensions to align with event libraries. It is mandatory to use one of the extension
functions to set the event base in the DNS context; this is required before
calling any event-driven calls like the <code>getdns</code> functions.</p>
<p>Each implementation of the DNS API will specify an extension function that
tells the DNS context which event base is being used. For example, one
implementation of this API that uses the libevent event library might name
this function "<code>getdns_extension_set_libevent_base()</code>" while
another might name it
"<code>getdns_extension_set_eventbase_for_libevent()</code>"; the two
extension functions could have very different calling patterns and return
values. Thus, the application developer <i>must</i> read the API documentation
(not just this design document) in order to determine what extension function
to use to tell the API the event base to use.</p>
<p>The structure of a typical event-driven application might look like the following pseudocode.
The code in italics is specific to the event mechanism.</p>
<pre>
Includes for one or more regular C libraries
<i>An include for the getdns library specific to the event library you use</i>
Definition of your callback function
Get the DNS data from the allocated pointer
Process that data
Check for errors
Definition of main()
Create context
<i>Set up your event base</i>
<i>Point the context to your event base</i>
Set up the getdns call arguments
Make the getdns call
Check if the getdns return is good
Destroy the context
Exit
</pre>
<p>The API does not have direct support for a polling interface. Instead, the callback interface is
specifically designed to allow an application that wants to process results in polling instead of in
callbacks to be able to create its own polling interface fairly trivially. Such a program would
create a data structure for the calls, including their <code>transaction_id</code> and
<code>userarg</code>. The <code>userarg</code> could be the polling data structure or have a pointer to it.
The application would have just
one callback function for all requests, and that function would copy the <code>response</code> into
application memory, update the data structure based on the <code>transaction_id</code> index,
and return from the callback. The polling code could then check the data structure for any updates
at its leisure.</p>
<h2>1.9 Calling the API Synchronously (Without Events)</h2>
<p>There are functions parallel to the four <code>getdns</code> async functions,
except that there is no callback. That is, when an application calls one of these
synchronous functions, the
API gathers all the required information and then returns the result. The value returned is exactly the
same as the response returned in the callback if you had used the async version of the function.</p>
<div class=forh>getdns_return_t
getdns_general_sync(
getdns_context *context,
const char *name,
uint16_t request_type,
getdns_dict *extensions,
getdns_dict **response
);
</div>
<div class=forh>getdns_return_t
getdns_address_sync(
getdns_context *context,
const char *name,
getdns_dict *extensions,
getdns_dict **response
);
</div>
<div class=forh>getdns_return_t
getdns_hostname_sync(
getdns_context *context,
getdns_dict *address,
getdns_dict *extensions,
getdns_dict **response
);
</div>
<div class=forh>getdns_return_t
getdns_service_sync(
getdns_context *context,
const char *name,
getdns_dict *extensions,
getdns_dict **response
);
</div>
<p>When you are done with the data in the response, use the following function so that the API can
free the memory from its internal pool.</p>
<div class=forh>void
getdns_dict_destroy(
getdns_dict *response
);
</div>
<h1>2. Data structures in the API</h1>
<p>The API returns data structures. The data structure is not a representational language like JSON:
it is really just a data structure. Data structures can have four types of members:</p>
<ul>
<li><span class=default>list</span> is an ordered list, like JSON and Python lists.
The members of the list can be any of the four data types.</li>
<li><span class=default>dict</span> is a name-value pair, like a JSON object or Python dict. The
name is a string literal, and the value can be any of the four data types. The order of the
name-value pairs in a dict is not important.</li>
<li><span class=default>int</span> is an integer compatible with uint32_t.</li>
<li><span class=default>bindata</span> is a struct to hold binary data. It is defined as
<code>{ size_t size; uint8_t *binary_stuff; }</code>.</li>
</ul>
<p>The API comes with helper functions to get data from the list and dict data types:</p>
<div class=forh id="datagetters">
/* Lists: get the length, get the data_type of the value at a given
position, and get the data at a given position */
getdns_return_t getdns_list_get_length(const getdns_list *list, size_t *answer);
getdns_return_t getdns_list_get_data_type(const getdns_list *list, size_t index, getdns_data_type *answer);
getdns_return_t getdns_list_get_dict(const getdns_list *list, size_t index, getdns_dict **answer);
getdns_return_t getdns_list_get_list(const getdns_list *list, size_t index, getdns_list **answer);
getdns_return_t getdns_list_get_bindata(const getdns_list *list, size_t index, getdns_bindata **answer);
getdns_return_t getdns_list_get_int(const getdns_list *list, size_t index, uint32_t *answer);
/* Dicts: get the list of names, get the data_type of the
value at a given name, and get the data at a given name */
getdns_return_t getdns_dict_get_names(const getdns_dict *dict, getdns_list **answer);
getdns_return_t getdns_dict_get_data_type(const getdns_dict *dict, const char *name, getdns_data_type *answer);
getdns_return_t getdns_dict_get_dict(const getdns_dict *dict, const char *name, getdns_dict **answer);
getdns_return_t getdns_dict_get_list(const getdns_dict *dict, const char *name, getdns_list **answer);
getdns_return_t getdns_dict_get_bindata(const getdns_dict *dict, const char *name, getdns_bindata **answer);
getdns_return_t getdns_dict_get_int(const getdns_dict *dict, const char *name, uint32_t *answer);
</div>
<p>All of these helper getter functions return <code>GETDNS_RETURN_GOOD</code> if the call is successful.
The list functions will return <code>GETDNS_RETURN_NO_SUCH_LIST_ITEM</code> if the index argument is
out of range; the dict functions will return <code>GETDNS_RETURN_NO_SUCH_DICT_NAME</code> if the name
argument doesn't exist in the dict. The functions also return <code>GETDNS_RETURN_WRONG_TYPE_REQUESTED</code>
if the requested data type doesn't match the contents of the indexed argument or name.</p>
<p>This document uses graphical representations of data structures. It is important to note that
this is only a graphical representation; the brackets, commas, quotation marks, comments, and so on
are not part of the data. Also, this document uses macro names instead of some of the int
arguments; of course, the data structures have the actual int in them.</p>
<p>The <code>getdns_dict_get_names</code> helper function creates a newly created list
containing the names in a dict. The caller is responsible for disposing this list.</p>
<p>The helper getter functions return references to <code>getdns_dict</code>, <code>getdns_list</code> and <code>getdns_bindata</code> data structures.
The user must not directly destroy these retrieved "child" data structures; instead,
they will automatically be destroyed when the containing "parent" data structure is destroyed.
Because of this, retrieved "child" data structures cannot be used any more after the containing "parent" data structure has been destroyed.</p>
<p>When the name parameter to the <code>getdns_dict_get_</code> functions, starts with a '<code>/</code>' (<code>%x2F</code>) character, it is interpreted as a JSON Pointer as described in RFC 6901, and will then be used to dereference the nested data structures to get to the requested data type.</p>
<h2>2.1 Creating Data Structures</h2>
<p>Some of the features of the API require that you create your own data structures to be used in
arguments passed to the API. For example, if you want to use any extensions for the calling functions,
you need to create a dict. The requisite functions are:</p>
<div class=forh id="datasetters">
/* Lists: create, destroy, and set the data at a given position */
getdns_list * getdns_list_create();
getdns_list * getdns_list_create_with_context(
getdns_context *context
);
getdns_list * getdns_list_create_with_memory_functions(
void *(*malloc)(size_t),
void *(*realloc)(void *, size_t),
void (*free)(void *)
);
getdns_list * getdns_list_create_with_extended_memory_functions(
void *userarg,
void *(*malloc)(void *userarg, size_t),
void *(*realloc)(void *userarg, void *, size_t),
void (*free)(void *userarg, void *)
);
void getdns_list_destroy(getdns_list *list);
getdns_return_t getdns_list_set_dict(getdns_list *list, size_t index, const getdns_dict *child_dict);
getdns_return_t getdns_list_set_list(getdns_list *list, size_t index, const getdns_list *child_list);
getdns_return_t getdns_list_set_bindata(getdns_list *list, size_t index, const getdns_bindata *child_bindata);
getdns_return_t getdns_list_set_int(getdns_list *list, size_t index, uint32_t child_uint32);
/* Dicts: create, destroy, and set the data at a given name */
getdns_dict * getdns_dict_create();
getdns_dict * getdns_dict_create_with_context(
getdns_context *context
);
getdns_dict * getdns_dict_create_with_memory_functions(
void *(*malloc)(size_t),
void *(*realloc)(void *, size_t),
void (*free)(void *)
);
getdns_dict * getdns_dict_create_with_extended_memory_functions(
void *userarg,
void *(*malloc)(void *userarg, size_t),
void *(*realloc)(void *userarg, void *, size_t),
void (*free)(void *userarg, void *)
);
void getdns_dict_destroy(getdns_dict *dict);
getdns_return_t getdns_dict_set_dict(getdns_dict *dict, const char *name, const getdns_dict *child_dict);
getdns_return_t getdns_dict_set_list(getdns_dict *dict, const char *name, const getdns_list *child_list);
getdns_return_t getdns_dict_set_bindata(getdns_dict *dict, const char *name, const getdns_bindata *child_bindata);
getdns_return_t getdns_dict_set_int(getdns_dict *dict, const char *name, uint32_t child_uint32);
getdns_return_t getdns_dict_remove_name(getdns_dict *dict, const char *name);
</div>
<p>Lists are extended with the <code>getdns_list_set_</code> calls with the <code>index</code> set to the
size of the list (such as 0 for an empty list). Dicts are extended with the <code>getdns_dict_set_</code> calls
with the <code>name</code> set to a name that does not yet exist. Name-value pairs are removed with
<code>getdns_dict_remove_name()</code>.</p>
<p>These helper setter functions return <code>GETDNS_RETURN_GOOD</code> if the call is successful.
The functions return <code>GETDNS_RETURN_WRONG_TYPE_REQUESTED</code> if the requested data type
doesn't match the contents of the indexed argument or name. The list functions will return
<code>GETDNS_RETURN_NO_SUCH_LIST_ITEM</code> if the index argument is higher than the length of the
list. <code>getdns_dict_remove_name()</code> will return
<code>GETDNS_RETURN_NO_SUCH_DICT_NAME</code> if the name argument doesn't exist in the dict. </p>
<p>The helper setter functions store copies of the given "child" values.
It is the responsibility of the caller to dispose of the original values.</p>
<p>When the name parameter to the <code>getdns_dict_set_</code> functions, starts with a '<code>/</code>' (<code>%x2F</code>) character, it is interpreted as a JSON Pointer as described in RFC 6901, and will then be used to dereference the nested data structures to set the given value at the specified name or list index.</p>
<h1>3. <a id="Extensions">Extensions</a></h1>
<p>Extensions are dict data structures. The names in the dict are the names of the extensions.
The definition of each extension describes the value associated with the name. For most extensions,
it is an on-off boolean, and the value is <code>GETDNS_EXTENSION_TRUE</code>. (There is
not currently a good reason to specify an extension name and give it a value of <code>GETDNS_EXTENSION_FALSE</code>,
but that is allowed by the API.)</p>
<p>For example, to create a dict for extensions and specify the extension to only return
results that have been validated with DNSSEC, you might use:</p>
<pre>
/* . . . */
getdns_dict * extensions = getdns_dict_create();
ret = getdns_dict_set_int(extensions, "dnssec_return_only_secure", GETDNS_EXTENSION_TRUE);
/* . . . Do some processing with the extensions and results . . . */
/* Remember to clean up memory*/
getdns_dict_destroy(extensions);
</pre>
<p>The extensions described in this section are are:
<ul>
<li><code>dnssec_return_status</code></li>
<li><code>dnssec_return_only_secure</code></li>
<li><code>dnssec_return_validation_chain</code></li>
<li><code>return_both_v4_and_v6</code></li>
<li><code>add_opt_parameters</code></li>
<li><code>add_warning_for_bad_dns</code></li>
<li><code>specify_class</code></li>
<li><code>return_call_reporting</code></li>
</ul>
<h2>3.1 Extensions for DNSSEC</h2>
<p>If an application wants the API to do DNSSEC validation for a request, it must set one or more DNSSEC-related extensions.
Note that the default is for none of these extensions to be set and the API will not perform DNSSEC.
Note that getting DNSSEC results can take longer in a few circumstances.</p>
<p>To return the DNSSEC status for each DNS record in the <code>replies_tree</code> list, use the
<code>dnssec_return_status</code> extension. The extension's value (an int) is set to
<code>GETDNS_EXTENSION_TRUE</code> to cause the returned status to have the name
<code>dnssec_status</code> (an int) added to the other names in the record's dict ("header",
"question", and so on). The values for that name are <code>GETDNS_DNSSEC_SECURE</code>,
<code>GETDNS_DNSSEC_BOGUS</code>, <code>GETDNS_DNSSEC_INDETERMINATE</code>, and
<code>GETDNS_DNSSEC_INSECURE</code>. Thus, a reply might look like:</p>
<pre>
{ # This is the first reply
"dnssec_status": GETDNS_DNSSEC_INDETERMINATE,
"header": { "id": 23456, "qr": 1, "opcode": 0, ... },
. . .
</pre>
<p>If instead of returning the status, you want to only see secure results, use the
<code>dnssec_return_only_secure</code> extension. The extension's value (an int) is set to
<code>GETDNS_EXTENSION_TRUE</code> to cause only records that the API can validate as secure with
DNSSEC to be returned in the <code>replies_tree</code> and <code>replies_full</code> lists. No
additional names are added to the dict of the record; the change is that some records might not
appear in the results. When this context option is set, if the API receives DNS replies but none
are determined to be secure, the error code at the top level of the response object is
<code>GETDNS_RESPSTATUS_NO_SECURE_ANSWERS</code>.</p>
<p>Applications that want to do their own validation will want to have the DNSSEC-related records
for a particular response. Use the <code>dnssec_return_validation_chain</code> extension. The
extension's value (an int) is set to <code>GETDNS_EXTENSION_TRUE</code> to cause a set
of additional DNSSEC-related records needed for validation to be returned in the response object.
This set comes as <code>validation_chain</code> (a list) at the top level of the response object.
This list includes all resource record dicts for all the resource records (DS, DNSKEY and their RRSIGs) that are needed to perform the validation from the root up. Thus, a reply might look like:</p>
<pre>
{ # This is the response object
"validation_chain":
[ { "name": <bindata for .>,
"type": GETDNS_RRTYPE_DNSKEY,
"rdata": { "flags": 256, . . . },
. . .
},
{ "name": <bindata for .>,
"type": GETDNS_RRTYPE_DNSKEY,
"rdata": { "flags": 257, . . . },
. . .
},
{ "name": <bindata for .>,
"type": GETDNS_RRTYPE_RRSIG,
"rdata": { "signers_name": <bindata for .>,
"type_covered": GETDNS_RRTYPE_DNSKEY,
. . .
},
},
{ "name": <bindata for com.>,
"type": GETDNS_RRTYPE_DS,
. . .
},
{ "name": <bindata for com.>,
"type": GETDNS_RRTYPE_RRSIG
"rdata": { "signers_name": <bindata for .>,
"type_covered": GETDNS_RRTYPE_DS,
. . .
},
. . .
},
{ "name": <bindata for com.>,
"type": GETDNS_RRTYPE_DNSKEY
"rdata": { "flags": 256, . . . },
. . .
},
{ "name": <bindata for com.>,
"type": GETDNS_RRTYPE_DNSKEY
"rdata": { "flags": 257, . . . },
. . .
},
{ "name": <bindata for com.>,
"type": GETDNS_RRTYPE_RRSIG
"rdata": { "signers_name": <bindata for com.>,
"type_covered": GETDNS_RRTYPE_DNSKEY,
. . .
},
. . .
},
{ "name": <bindata for example.com.>,
"type": GETDNS_RRTYPE_DS,
. . .
},
{ "name": <bindata for example.com.>,
"type": GETDNS_RRTYPE_RRSIG
"rdata": { "signers_name": <bindata for com.>,
"type_covered": GETDNS_RRTYPE_DS,
. . .
},
. . .
},
{ "name": <bindata for example.com.>,
"type": GETDNS_RRTYPE_DNSKEY
"rdata": { "flags": 257, ... },
. . .
},
. . .
]
"replies_tree":
[
. . .
</pre>
<p>Implementations not capable of performing DNSSEC in stub resolution mode may
indicate this by not performing a request and instead return an error of
<code>GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED</code> when using a context
in which stub resolution is set, and having any of the
<code>dnssec_return_status</code>, <code>dnssec_return_only_secure</code>, or
<code>dnssec_return_validation_chain</code> extensions specified.</p>
<h2>3.2 Returning Both IPv4 and IPv6 Responses</h2>
<p>Many applications want to get both IPv4 and IPv6 addresses in a single call so that the results
can be processed together. The <code>getdns_address</code> and <code>getdns_address_sync</code>
functions are able to do this automatically. If you are using the <code>getdns_general</code> or
<code>getdns_general_sync</code> function, you can enable this with the
<code>return_both_v4_and_v6</code> extension. The extension's value (an int) is set to
<code>GETDNS_EXTENSION_TRUE</code> to cause the results to be the lookup of either A or AAAA records
to include any A and AAAA records for the queried name (otherwise, the extension does nothing).
These results are expected to be used with Happy Eyeballs systems that will find the best socket for
an application.</p>
<h2>3.3 Setting Up OPT Resource Records</h2>
<p>For lookups that need an OPT resource record in the Additional Data section, use the
<code>add_opt_parameters</code> extension. The extension's value (a dict) contains the
parameters; these are described in more detail in RFC 6891. They are:</p>
<ul>
<li><code>maximum_udp_payload_size</code> (an int), a value between 512 and 65535; if not specified,
this defaults to those from the DNS context</li>
<li><code>extended_rcode</code> (an int), a value between 0 and 255; if not specified,
this defaults to those from the DNS context</li>
<li><code>version</code> (an int), a value between 0 and 255; if not specified, this
defaults to 0</li>
<li><code>do_bit</code> (an int), a value between 0 and 1; if not specified, this defaults
to those from the DNS context</li>
<li><code>options</code> (a list) contains dicts for each option to be specified.
Each list time contains two names: <code>option_code</code> (an int) and <code>option_data</code>
(a bindata). The API marshalls the entire set of options into a properly-formatted RDATA
for the resource record.</li>
</ul>
<p>It is very important to note that the OPT resource record specified in the
<code>add_opt_parameters</code> extension might not be the same the one that the API sends in the
query. For example, if the application also includes any of the DNSSEC extensions, the API will make
sure that the OPT resource record sets the resource record appropriately, making the needed changes
to the settings from the <code>add_opt_parameters</code> extension.</p>
<p>The use of this extension can conflict with the values in the DNS context. For example,
the default for an OS might be a maximum payload size of 65535, but the extension might specify
1550. In such a case, the API will honor the values stated in the extension, but will honor the
values from the DNS context if values are not given in the extension.</p>
<h2>3.4 Getting Warnings for Responses that Violate the DNS Standard</h2>
<p>To receive a warning if a particular response violates some parts of the DNS standard, use
the <code>add_warning_for_bad_dns</code> extension. The extension's value (an int) is set to
<code>GETDNS_EXTENSION_TRUE</code> to cause each reply in the <code>replies_tree</code>
to contain an additional name, <code>bad_dns</code> (a list). The list is zero or more
ints that indicate types of bad DNS found in that reply. The list of values is:
<p class=define>GETDNS_BAD_DNS_CNAME_IN_TARGET</p>
<p class=descrip>A DNS query type that does not allow a target to be a CNAME pointed to a CNAME</p>
<p class=define>GETDNS_BAD_DNS_ALL_NUMERIC_LABEL</p>
<p class=descrip>One or more labels in a returned domain name is all-numeric; this is not legal for a hostname</p>
<p class=define>GETDNS_BAD_DNS_CNAME_RETURNED_FOR_OTHER_TYPE</p>
<p class=descrip>A DNS query for a type other than CNAME returned a CNAME response</p>
<h2>3.5 Using Other Class Types</h2>
<p>The vast majority of DNS requests are made with the Internet (IN) class. To make a request in a
different DNS class, use, the <code>specify_class</code> extension. The extension's value (an int)
contains the class number. Few applications will ever use this extension.</p>
<h2>3.6 Extensions Relating to the API</h2>
<p>An application might want to see debugging information for queries such as the length of time it
takes for each query to return to the API. Use the <code>return_call_reporting</code> extension. The
extension's value (an int) is set to <code>GETDNS_EXTENSION_TRUE</code> to add the name
<code>call_reporting</code> (a list) to the top level of the response object. Each member of the
list is a dict that represents one call made for the call to the API. Each member has the following
names:</p>
<ul>
<li><code>query_name</code> (a bindata) is the name that was sent</li>
<li><code>query_type</code> (an int) is the type that was queried for</li>
<li><code>query_to</code> (a bindata) is the address to which the query was sent</li>
<li><code>run_time/ms</code> (a bindata) is the difference between the time the successful
query started and ended in milliseconds, represented
as a uint32_t (this does not include time taken for connection set up
or transport fallback)</li>
<li><code>entire_reply</code> (a bindata) is the entire response received</li>
<li><code>dnssec_result</code> (an int) is the DNSSEC status, or <code>GETDNS_DNSSEC_NOT_PERFORMED</code>
if DNSSEC validation was not performed</li>
</ul>
<h1>4. Response Data from Queries</h1>
<p>The callback function contains a pointer to a response object.
A response object is always a dict. The response
object always contains at least three names: <code>replies_full</code> (a list) and
<code>replies_tree</code> (a list), and <code>status</code> (an int).
<code>replies_full</code> is a list of DNS replies (each is bindata) as they appear on the wire.
<code>replies_tree</code> is a list of DNS replies (each is a dict) with the various part of the
reply parsed out. <code>status</code> is a status code for the query.</p>
<p>Because the API might be extended in the future, a response object might also contain names other
than <code>replies_full</code>, <code>replies_tree</code>, and <code>status</code>. Similarly, any
of the dicts described here might be extended in later versions of the API. Thus, an application
using the API must not assume that it knows all possible names in a dict.</p>
<p>The following lists the status codes for response objects. Note that, if the status is that there
are no responses for the query, the lists in <code>replies_full</code> and <code>replies_tree</code>
will have zero length.</p>
<p class=define>GETDNS_RESPSTATUS_GOOD</p>
<p class=descrip>At least one response was returned</p>
<p class=define>GETDNS_RESPSTATUS_NO_NAME</p>
<p class=descrip>Queries for the name yielded all negative responses</p>
<p class=define>GETDNS_RESPSTATUS_ALL_TIMEOUT</p>
<p class=descrip>All queries for the name timed out</p>
<p class=define>GETDNS_RESPSTATUS_NO_SECURE_ANSWERS</p>
<p class=descrip>The context setting for getting only secure responses was specified, and at least one DNS response was received, but no DNS response was determined to be secure through DNSSEC.</p>
<p class=define>GETDNS_RESPSTATUS_ALL_BOGUS_ANSWERS</p>
<p class=descrip>The context setting for getting only secure responses was specified, and at least one DNS response was received, but all received responses for the requested name were bogus.</p>
<p>The top level of <code>replies_tree</code> can optionally have the following names: <code>canonical_name</code> (a
bindata), <code>intermediate_aliases</code> (a list), <code>answer_ipv4_address</code> (a bindata),
<code>answer_ipv6_address</code> (a bindata), and <code>answer_type</code> (an int).</p>
<ul>
<li>The value of <code>canonical_name</code> is the name that the API used for its lookup. It is in
FQDN presentation format.</li>
<li>The values in the <code>intermediate_aliases</code> list are domain names from any CNAME or
unsynthesized DNAME found when resolving the original query. The list might have zero entries
if there were no CNAMEs in the path. These may be useful, for example, for name comparisons
when following the rules in RFC 6125.</li>
<li>The value of <code>answer_ipv4_address</code> and <code>answer_ipv6_address</code> are
the addresses of the server from which the answer was received.</li>
<li>The value of <code>answer_type</code> is the type of name service that generated the response.
The values are:</li>
</ul>
<p class=define>GETDNS_NAMETYPE_DNS</p>
<p class=descrip>Normal DNS (RFC 1035)</p>
<p class=define>GETDNS_NAMETYPE_WINS</p>
<p class=descrip>The WINS name service (some reference needed)</p>
<p>If the call was <code>getdns_address</code> or <code>getdns_address_sync</code>, the top level
of <code>replies_tree</code> has an additional name, <code>just_address_answers</code> (a list).
The value of <code>just_address_answers</code> is a list that contains all of the A and AAAA
records from the answer sections of any of the replies, in the order they appear in the replies.
Each item in the list is a dict with at least two names: <code>address_type</code> (whose value is
a bindata; it is currently either "IPv4" or "IPv6") and <code>address_data</code> (whose value is a bindata).
Note that the <code>dnssec_return_only_secure</code> extension affects
what will appear in the <code>just_address_answers</code> list. Also note if later versions of the
DNS return other address types, those types will appear in this list as well.</p>
<p>The API can make service discovery through SRV records easier. If
the call was <code>getdns_service</code> or <code>getdns_service_sync</code>,
the top level of <code>replies_tree</code> has an additional name,
<code>srv_addresses</code> (a list).
The list is ordered by priority and weight based on the weighting
algorithm in RFC 2782, lowest priority value first. Each element
of the list is dict has at least two names: <code>port</code> and <code>domain_name</code>. If the
API was able to determine the address of the target domain name (such as from its cache or from the
Additional section of responses), the dict for an element will also contain
<code>address_type</code> (whose value is a bindata; it is currently either "IPv4" or "IPv6") and
<code>address_data</code> (whose value is a bindata). Note that the
<code>dnssec_return_only_secure</code> extension affects what will appear in the
<code>srv_addresses</code> list.</p>
<h2>4.1 Structure of DNS <code>replies_tree</code></h2>
<p>The names in each entry in the the <code>replies_tree</code> list for DNS responses include
<code>header</code> (a dict), <code>question</code> (a dict), <code>answer</code> (a list),
<code>authority</code> (a list), and <code>additional</code> (a list), corresponding to the sections
in the DNS message format. The answer, authority, and additional lists each contain zero or more
dicts, with each dict in each list representing a resource record.</p>
<p>The names in the <code>header</code> dict are all the fields from Section 4.1.1. of RFC 1035.
They are: <code>id</code>, <code>qr</code>, <code>opcode</code>, <code>aa</code>, <code>tc</code>,
<code>rd</code>, <code>ra</code>, <code>z</code>, <code>rcode</code>, <code>qdcount</code>,
<code>ancount</code>, <code>nscount</code>, and <code>arcount</code>. All are ints.</p>
<p>The names in the <code>question</code> dict are the three fields from Section 4.1.2. of RFC 1035:
<code>qname</code> (a bindata), <code>qtype</code> (an int), and <code>qclass</code> (an int).</p>
<p>Resource records are a bit different than headers and question sections in that the RDATA portion
often has its own structure. The other names in the resource record dicts are <code>name</code> (a
bindata), <code>type</code> (an int), <code>class</code> (an int), <code>ttl</code> (an int) and
<code>rdata</code> (a dict); there is no name equivalent to the RDLENGTH field.
The <code>OPT</code> resource record does not have the <code>class</code> and the <code>ttl</code> name, but in stead provides <code>udp_payload_size</code> (an int), <code>extended_rcode</code> (an int), <code>version</code> (an int), <code>do</code> (an int), and <code>z</code> (an int).</p>
<p>The <code>rdata</code> dict has different names for each response type. There is a <a
href="#TypeList">complete list of the types defined</a> in the API. For names that end in
"-obsolete" or "-unknown", the bindata is the entire RDATA field. For example, the
<code>rdata</code> for an A record has a name <code>ipv4_address</code> (a bindata); the
<code>rdata</code> for an SRV record has the names <code>priority</code> (an int),
<code>weight</code> (an int), <code>port</code> (an int), and <code>target</code> (a bindata).</p>
<p>Each <code>rdata</code> dict also has a <code>rdata_raw</code> field (a bindata). This is useful
for types not defined in this version of the API. It also might be of value if a later version of