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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
|
/* rr.c
*
* access functions for ldns_rr -
* a Net::DNS like library for C
* LibDNS Team @ NLnet Labs
*
* (c) NLnet Labs, 2004-2006
* See the file LICENSE for the license
*/
#include <ldns/config.h>
#include <ldns/ldns.h>
#include <strings.h>
#include <limits.h>
#include <errno.h>
#define LDNS_SYNTAX_DATALEN 16
#define LDNS_TTL_DATALEN 21
#define LDNS_RRLIST_INIT 8
ldns_rr *
ldns_rr_new(void)
{
ldns_rr *rr;
rr = LDNS_MALLOC(ldns_rr);
if (!rr) {
return NULL;
}
ldns_rr_set_owner(rr, NULL);
ldns_rr_set_question(rr, false);
ldns_rr_set_rd_count(rr, 0);
rr->_rdata_fields = NULL;
ldns_rr_set_class(rr, LDNS_RR_CLASS_IN);
ldns_rr_set_ttl(rr, LDNS_DEFAULT_TTL);
return rr;
}
ldns_rr *
ldns_rr_new_frm_type(ldns_rr_type t)
{
ldns_rr *rr;
const ldns_rr_descriptor *desc;
size_t i;
rr = LDNS_MALLOC(ldns_rr);
if (!rr) {
return NULL;
}
desc = ldns_rr_descript(t);
rr->_rdata_fields = LDNS_XMALLOC(ldns_rdf *, ldns_rr_descriptor_minimum(desc));
if(!rr->_rdata_fields) {
LDNS_FREE(rr);
return NULL;
}
for (i = 0; i < ldns_rr_descriptor_minimum(desc); i++) {
rr->_rdata_fields[i] = NULL;
}
ldns_rr_set_owner(rr, NULL);
ldns_rr_set_question(rr, false);
/* set the count to minimum */
ldns_rr_set_rd_count(rr, ldns_rr_descriptor_minimum(desc));
ldns_rr_set_class(rr, LDNS_RR_CLASS_IN);
ldns_rr_set_ttl(rr, LDNS_DEFAULT_TTL);
ldns_rr_set_type(rr, t);
return rr;
}
void
ldns_rr_free(ldns_rr *rr)
{
size_t i;
if (rr) {
if (ldns_rr_owner(rr)) {
ldns_rdf_deep_free(ldns_rr_owner(rr));
}
for (i = 0; i < ldns_rr_rd_count(rr); i++) {
ldns_rdf_deep_free(ldns_rr_rdf(rr, i));
}
LDNS_FREE(rr->_rdata_fields);
LDNS_FREE(rr);
}
}
/*
* trailing spaces are allowed
* leading spaces are not allowed
* allow ttl to be optional
* class is optional too
* if ttl is missing, and default_ttl is 0, use DEF_TTL
* allow ttl to be written as 1d3h
* So the RR should look like. e.g.
* miek.nl. 3600 IN MX 10 elektron.atoom.net
* or
* miek.nl. 1h IN MX 10 elektron.atoom.net
* or
* miek.nl. IN MX 10 elektron.atoom.net
*/
static ldns_status
ldns_rr_new_frm_str_internal(ldns_rr **newrr, const char *str,
uint32_t default_ttl, ldns_rdf *origin,
ldns_rdf **prev, bool question)
{
ldns_rr *new;
const ldns_rr_descriptor *desc;
ldns_rr_type rr_type;
ldns_buffer *rr_buf = NULL;
ldns_buffer *rd_buf = NULL;
uint32_t ttl_val;
char *owner = NULL;
char *ttl = NULL;
ldns_rr_class clas_val;
char *clas = NULL;
char *type = NULL;
char *rdata = NULL;
char *rd = NULL;
char * b64 = NULL;
size_t rd_strlen;
const char *delimiters;
ssize_t c;
ldns_rdf *owner_dname;
const char* endptr;
int was_unknown_rr_format = 0;
ldns_status status = LDNS_STATUS_OK;
/* used for types with unknown number of rdatas */
bool done;
bool quoted;
ldns_rdf *r = NULL;
uint16_t r_cnt;
uint16_t r_min;
uint16_t r_max;
size_t pre_data_pos;
new = ldns_rr_new();
owner = LDNS_XMALLOC(char, LDNS_MAX_DOMAINLEN + 1);
ttl = LDNS_XMALLOC(char, LDNS_TTL_DATALEN);
clas = LDNS_XMALLOC(char, LDNS_SYNTAX_DATALEN);
rdata = LDNS_XMALLOC(char, LDNS_MAX_PACKETLEN + 1);
rr_buf = LDNS_MALLOC(ldns_buffer);
rd_buf = LDNS_MALLOC(ldns_buffer);
rd = LDNS_XMALLOC(char, LDNS_MAX_RDFLEN);
b64 = LDNS_XMALLOC(char, LDNS_MAX_RDFLEN);
if (!new || !owner || !ttl || !clas || !rdata || !rr_buf || !rd_buf || !rd || !b64 ) {
status = LDNS_STATUS_MEM_ERR;
LDNS_FREE(rr_buf);
goto ldnserror;
}
ldns_buffer_new_frm_data(rr_buf, (char*)str, strlen(str));
/* split the rr in its parts -1 signals trouble */
if (ldns_bget_token(rr_buf, owner, "\t\n ", LDNS_MAX_DOMAINLEN) == -1) {
status = LDNS_STATUS_SYNTAX_ERR;
ldns_buffer_free(rr_buf);
goto ldnserror;
}
if (ldns_bget_token(rr_buf, ttl, "\t\n ", LDNS_TTL_DATALEN) == -1) {
status = LDNS_STATUS_SYNTAX_TTL_ERR;
ldns_buffer_free(rr_buf);
goto ldnserror;
}
ttl_val = (uint32_t) ldns_str2period(ttl, &endptr);
if (strlen(ttl) > 0 && !isdigit((int) ttl[0])) {
/* ah, it's not there or something */
if (default_ttl == 0) {
ttl_val = LDNS_DEFAULT_TTL;
} else {
ttl_val = default_ttl;
}
/* we not ASSUMING the TTL is missing and that
* the rest of the RR is still there. That is
* CLASS TYPE RDATA
* so ttl value we read is actually the class
*/
clas_val = ldns_get_rr_class_by_name(ttl);
/* class can be left out too, assume IN, current
* token must be type
*/
if (clas_val == 0) {
clas_val = LDNS_RR_CLASS_IN;
type = LDNS_XMALLOC(char, strlen(ttl) + 1);
if(!type) {
status = LDNS_STATUS_MEM_ERR;
ldns_buffer_free(rr_buf);
goto ldnserror;
}
strncpy(type, ttl, strlen(ttl) + 1);
}
} else {
if (ldns_bget_token(rr_buf, clas, "\t\n ", LDNS_SYNTAX_DATALEN) == -1) {
status = LDNS_STATUS_SYNTAX_CLASS_ERR;
ldns_buffer_free(rr_buf);
goto ldnserror;
}
clas_val = ldns_get_rr_class_by_name(clas);
/* class can be left out too, assume IN, current
* token must be type
*/
if (clas_val == 0) {
clas_val = LDNS_RR_CLASS_IN;
type = LDNS_XMALLOC(char, strlen(clas) + 1);
if(!type) {
status = LDNS_STATUS_MEM_ERR;
ldns_buffer_free(rr_buf);
goto ldnserror;
}
strncpy(type, clas, strlen(clas) + 1);
}
}
/* the rest should still be waiting for us */
if (!type) {
type = LDNS_XMALLOC(char, LDNS_SYNTAX_DATALEN);
if(!type) {
status = LDNS_STATUS_MEM_ERR;
ldns_buffer_free(rr_buf);
goto ldnserror;
}
if (ldns_bget_token(rr_buf, type, "\t\n ", LDNS_SYNTAX_DATALEN) == -1) {
status = LDNS_STATUS_SYNTAX_TYPE_ERR;
ldns_buffer_free(rr_buf);
goto ldnserror;
}
}
if (ldns_bget_token(rr_buf, rdata, "\0", LDNS_MAX_PACKETLEN) == -1) {
/* apparently we are done, and it's only a question RR
* so do not set status and go to ldnserror here
*/
}
ldns_buffer_new_frm_data(rd_buf, rdata, strlen(rdata));
if (strlen(owner) <= 1 && strncmp(owner, "@", 1) == 0) {
if (origin) {
ldns_rr_set_owner(new, ldns_rdf_clone(origin));
} else if (prev && *prev) {
ldns_rr_set_owner(new, ldns_rdf_clone(*prev));
} else {
/* default to root */
ldns_rr_set_owner(new, ldns_dname_new_frm_str("."));
}
/* @ also overrides prev */
if (prev) {
ldns_rdf_deep_free(*prev);
*prev = ldns_rdf_clone(ldns_rr_owner(new));
if (!*prev) {
status = LDNS_STATUS_MEM_ERR;
ldns_buffer_free(rr_buf);
goto ldnserror;
}
}
} else {
if (strlen(owner) == 0) {
/* no ownername was given, try prev, if that fails
* origin, else default to root */
if (prev && *prev) {
ldns_rr_set_owner(new, ldns_rdf_clone(*prev));
} else if (origin) {
ldns_rr_set_owner(new, ldns_rdf_clone(origin));
} else {
ldns_rr_set_owner(new, ldns_dname_new_frm_str("."));
}
if(!ldns_rr_owner(new)) {
status = LDNS_STATUS_MEM_ERR;
ldns_buffer_free(rr_buf);
goto ldnserror;
}
} else {
owner_dname = ldns_dname_new_frm_str(owner);
if (!owner_dname) {
status = LDNS_STATUS_SYNTAX_ERR;
ldns_buffer_free(rr_buf);
goto ldnserror;
}
ldns_rr_set_owner(new, owner_dname);
if (!ldns_dname_str_absolute(owner) && origin) {
if(ldns_dname_cat(ldns_rr_owner(new),
origin) != LDNS_STATUS_OK) {
status = LDNS_STATUS_SYNTAX_ERR;
ldns_buffer_free(rr_buf);
goto ldnserror;
}
}
if (prev) {
ldns_rdf_deep_free(*prev);
*prev = ldns_rdf_clone(ldns_rr_owner(new));
if(!*prev) {
status = LDNS_STATUS_MEM_ERR;
ldns_buffer_free(rr_buf);
goto ldnserror;
}
}
}
}
LDNS_FREE(owner);
owner = NULL;
ldns_rr_set_question(new, question);
ldns_rr_set_ttl(new, ttl_val);
LDNS_FREE(ttl);
ttl = NULL;
ldns_rr_set_class(new, clas_val);
LDNS_FREE(clas);
clas = NULL;
rr_type = ldns_get_rr_type_by_name(type);
LDNS_FREE(type);
type = NULL;
desc = ldns_rr_descript((uint16_t)rr_type);
ldns_rr_set_type(new, rr_type);
if (desc) {
/* only the rdata remains */
r_max = ldns_rr_descriptor_maximum(desc);
r_min = ldns_rr_descriptor_minimum(desc);
} else {
r_min = 0;
r_max = 1;
}
/* depending on the rr_type we need to extract
* the rdata differently, e.g. NSEC/NSEC3 */
switch(rr_type) {
default:
done = false;
for (r_cnt = 0; !done && r_cnt < r_max; r_cnt++) {
quoted = false;
/* if type = B64, the field may contain spaces */
if (ldns_rr_descriptor_field_type(desc,
r_cnt) == LDNS_RDF_TYPE_B64 ||
ldns_rr_descriptor_field_type(desc,
r_cnt) == LDNS_RDF_TYPE_HEX ||
ldns_rr_descriptor_field_type(desc,
r_cnt) == LDNS_RDF_TYPE_LOC ||
ldns_rr_descriptor_field_type(desc,
r_cnt) == LDNS_RDF_TYPE_WKS ||
ldns_rr_descriptor_field_type(desc,
r_cnt) == LDNS_RDF_TYPE_IPSECKEY ||
ldns_rr_descriptor_field_type(desc,
r_cnt) == LDNS_RDF_TYPE_NSEC) {
delimiters = "\n\t";
} else {
delimiters = "\n\t ";
}
if (ldns_rr_descriptor_field_type(desc,
r_cnt) == LDNS_RDF_TYPE_STR &&
ldns_buffer_remaining(rd_buf) > 0) {
/* skip spaces */
while (*(ldns_buffer_current(rd_buf)) == ' ') {
ldns_buffer_skip(rd_buf, 1);
}
if (*(ldns_buffer_current(rd_buf)) == '\"') {
delimiters = "\"\0";
ldns_buffer_skip(rd_buf, 1);
quoted = true;
}
}
/* because number of fields can be variable, we can't
rely on _maximum() only */
/* skip spaces */
while (ldns_buffer_position(rd_buf) < ldns_buffer_limit(rd_buf) &&
*(ldns_buffer_current(rd_buf)) == ' ' && !quoted
) {
ldns_buffer_skip(rd_buf, 1);
}
pre_data_pos = ldns_buffer_position(rd_buf);
if ((c = ldns_bget_token(rd_buf, rd, delimiters,
LDNS_MAX_RDFLEN)) != -1) {
/* hmmz, rfc3597 specifies that any type can be represented with
* \# method, which can contain spaces...
* it does specify size though...
*/
rd_strlen = strlen(rd);
/* unknown RR data */
if (strncmp(rd, "\\#", 2) == 0 && !quoted && (rd_strlen == 2 || rd[2]==' ')) {
uint16_t hex_data_size;
char *hex_data_str;
uint16_t cur_hex_data_size;
was_unknown_rr_format = 1;
/* go back to before \# and skip it while setting delimiters better */
ldns_buffer_set_position(rd_buf, pre_data_pos);
delimiters = "\n\t ";
(void)ldns_bget_token(rd_buf, rd, delimiters, LDNS_MAX_RDFLEN);
/* read rdata octet length */
c = ldns_bget_token(rd_buf, rd, delimiters, LDNS_MAX_RDFLEN);
if (c == -1) {
/* something goes very wrong here */
LDNS_FREE(rd);
LDNS_FREE(b64);
ldns_buffer_free(rd_buf);
ldns_buffer_free(rr_buf);
LDNS_FREE(rdata);
ldns_rr_free(new);
return LDNS_STATUS_SYNTAX_RDATA_ERR;
}
hex_data_size = (uint16_t) atoi(rd);
/* copy the hex chars into hex str (which is 2 chars per byte) */
hex_data_str = LDNS_XMALLOC(char, 2 * hex_data_size + 1);
if (!hex_data_str) {
/* malloc error */
LDNS_FREE(rd);
LDNS_FREE(b64);
ldns_buffer_free(rd_buf);
ldns_buffer_free(rr_buf);
LDNS_FREE(rdata);
ldns_rr_free(new);
return LDNS_STATUS_SYNTAX_RDATA_ERR;
}
cur_hex_data_size = 0;
while(cur_hex_data_size < 2 * hex_data_size) {
c = ldns_bget_token(rd_buf, rd, delimiters, LDNS_MAX_RDFLEN);
if (c != -1) {
rd_strlen = strlen(rd);
}
if (c == -1 || (size_t)cur_hex_data_size + rd_strlen > 2 * (size_t)hex_data_size) {
LDNS_FREE(hex_data_str);
LDNS_FREE(rd);
LDNS_FREE(b64);
ldns_buffer_free(rd_buf);
ldns_buffer_free(rr_buf);
LDNS_FREE(rdata);
ldns_rr_free(new);
return LDNS_STATUS_SYNTAX_RDATA_ERR;
}
strncpy(hex_data_str + cur_hex_data_size, rd, rd_strlen);
cur_hex_data_size += rd_strlen;
}
hex_data_str[cur_hex_data_size] = '\0';
/* correct the rdf type */
/* if *we* know the type, interpret it as wireformat */
if (desc) {
size_t hex_pos = 0;
uint8_t *hex_data = LDNS_XMALLOC(uint8_t, hex_data_size + 2);
ldns_status s;
if(!hex_data) {
LDNS_FREE(hex_data_str);
LDNS_FREE(rd);
LDNS_FREE(b64);
ldns_buffer_free(rd_buf);
ldns_buffer_free(rr_buf);
LDNS_FREE(rdata);
ldns_rr_free(new);
return LDNS_STATUS_MEM_ERR;
}
ldns_write_uint16(hex_data, hex_data_size);
ldns_hexstring_to_data(hex_data + 2, hex_data_str);
s = ldns_wire2rdf(new, hex_data,
hex_data_size+2, &hex_pos);
if(s != LDNS_STATUS_OK) {
LDNS_FREE(hex_data_str);
LDNS_FREE(rd);
LDNS_FREE(b64);
ldns_buffer_free(rd_buf);
ldns_buffer_free(rr_buf);
LDNS_FREE(rdata);
ldns_rr_free(new);
LDNS_FREE(hex_data);
return s;
}
LDNS_FREE(hex_data);
} else {
r = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_HEX, hex_data_str);
if(!r) {
LDNS_FREE(hex_data_str);
LDNS_FREE(rd);
LDNS_FREE(b64);
ldns_buffer_free(rd_buf);
ldns_buffer_free(rr_buf);
LDNS_FREE(rdata);
ldns_rr_free(new);
return LDNS_STATUS_MEM_ERR;
}
ldns_rdf_set_type(r, LDNS_RDF_TYPE_UNKNOWN);
if(!ldns_rr_push_rdf(new, r)) {
LDNS_FREE(hex_data_str);
LDNS_FREE(rd);
LDNS_FREE(b64);
ldns_buffer_free(rd_buf);
ldns_buffer_free(rr_buf);
LDNS_FREE(rdata);
ldns_rr_free(new);
return LDNS_STATUS_MEM_ERR;
}
}
LDNS_FREE(hex_data_str);
} else {
/* Normal RR */
switch(ldns_rr_descriptor_field_type(desc, r_cnt)) {
case LDNS_RDF_TYPE_HEX:
case LDNS_RDF_TYPE_B64:
/* can have spaces, and will always be the last
* record of the rrdata. Read in the rest */
if ((c = ldns_bget_token(rd_buf,
b64,
"\n",
LDNS_MAX_RDFLEN))
!= -1) {
rd = strncat(rd,
b64,
LDNS_MAX_RDFLEN
- strlen(rd) - 1);
}
r = ldns_rdf_new_frm_str(
ldns_rr_descriptor_field_type(desc, r_cnt),
rd);
break;
case LDNS_RDF_TYPE_DNAME:
r = ldns_rdf_new_frm_str(
ldns_rr_descriptor_field_type(desc, r_cnt),
rd);
/* check if the origin should be used or concatenated */
if (r && ldns_rdf_size(r) > 1 && ldns_rdf_data(r)[0] == 1
&& ldns_rdf_data(r)[1] == '@') {
ldns_rdf_deep_free(r);
if (origin) {
r = ldns_rdf_clone(origin);
} else {
/* if this is the SOA, use its own owner name */
if (rr_type == LDNS_RR_TYPE_SOA) {
r = ldns_rdf_clone(ldns_rr_owner(new));
} else {
r = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, ".");
}
}
} else if (r && rd_strlen >= 1 && !ldns_dname_str_absolute(rd) && origin) {
if (ldns_dname_cat(r, origin) != LDNS_STATUS_OK) {
LDNS_FREE(rd);
LDNS_FREE(b64);
ldns_buffer_free(rd_buf);
ldns_buffer_free(rr_buf);
LDNS_FREE(rdata);
ldns_rr_free(new);
return LDNS_STATUS_ERR;
}
}
break;
default:
r = ldns_rdf_new_frm_str(
ldns_rr_descriptor_field_type(desc, r_cnt),
rd);
break;
}
if (r) {
ldns_rr_push_rdf(new, r);
} else {
LDNS_FREE(rd);
LDNS_FREE(b64);
ldns_buffer_free(rd_buf);
ldns_buffer_free(rr_buf);
LDNS_FREE(rdata);
ldns_rr_free(new);
return LDNS_STATUS_SYNTAX_RDATA_ERR;
}
}
if (quoted) {
if (ldns_buffer_available(rd_buf, 1)) {
ldns_buffer_skip(rd_buf, 1);
} else {
done = true;
}
}
} else {
done = true;
}
}
}
LDNS_FREE(rd);
LDNS_FREE(b64);
ldns_buffer_free(rd_buf);
ldns_buffer_free(rr_buf);
LDNS_FREE(rdata);
if (!question && desc && !was_unknown_rr_format && ldns_rr_rd_count(new) < r_min) {
ldns_rr_free(new);
return LDNS_STATUS_SYNTAX_MISSING_VALUE_ERR;
}
if (newrr) {
*newrr = new;
} else {
/* Maybe the caller just wanted to see if it would parse? */
ldns_rr_free(new);
}
return LDNS_STATUS_OK;
ldnserror:
LDNS_FREE(type);
LDNS_FREE(owner);
LDNS_FREE(ttl);
LDNS_FREE(clas);
LDNS_FREE(rdata);
LDNS_FREE(rd);
LDNS_FREE(rd_buf);
LDNS_FREE(b64);
ldns_rr_free(new);
return status;
}
ldns_status
ldns_rr_new_frm_str(ldns_rr **newrr, const char *str,
uint32_t default_ttl, ldns_rdf *origin,
ldns_rdf **prev)
{
return ldns_rr_new_frm_str_internal(newrr,
str,
default_ttl,
origin,
prev,
false);
}
ldns_status
ldns_rr_new_question_frm_str(ldns_rr **newrr, const char *str,
ldns_rdf *origin, ldns_rdf **prev)
{
return ldns_rr_new_frm_str_internal(newrr,
str,
0,
origin,
prev,
true);
}
ldns_status
ldns_rr_new_frm_fp(ldns_rr **newrr, FILE *fp, uint32_t *ttl, ldns_rdf **origin, ldns_rdf **prev)
{
return ldns_rr_new_frm_fp_l(newrr, fp, ttl, origin, prev, NULL);
}
ldns_status
ldns_rr_new_frm_fp_l(ldns_rr **newrr, FILE *fp, uint32_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev, int *line_nr)
{
char *line;
const char *endptr; /* unused */
ldns_rr *rr;
uint32_t ttl;
ldns_rdf *tmp;
ldns_status s;
ssize_t size;
int offset = 0;
if (default_ttl) {
ttl = *default_ttl;
} else {
ttl = 0;
}
line = LDNS_XMALLOC(char, LDNS_MAX_LINELEN + 1);
if (!line) {
return LDNS_STATUS_MEM_ERR;
}
/* read an entire line in from the file */
if ((size = ldns_fget_token_l(fp, line, LDNS_PARSE_SKIP_SPACE, LDNS_MAX_LINELEN, line_nr)) == -1) {
LDNS_FREE(line);
/* if last line was empty, we are now at feof, which is not
* always a parse error (happens when for instance last line
* was a comment)
*/
return LDNS_STATUS_SYNTAX_ERR;
}
/* we can have the situation, where we've read ok, but still got
* no bytes to play with, in this case size is 0
*/
if (size == 0) {
LDNS_FREE(line);
return LDNS_STATUS_SYNTAX_EMPTY;
}
if (strncmp(line, "$ORIGIN", 7) == 0 && isspace(line[7])) {
if (*origin) {
ldns_rdf_deep_free(*origin);
*origin = NULL;
}
offset = 8;
while (isspace(line[offset])) {
offset++;
}
tmp = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, line + offset);
if (!tmp) {
/* could not parse what next to $ORIGIN */
LDNS_FREE(line);
return LDNS_STATUS_SYNTAX_DNAME_ERR;
}
*origin = tmp;
s = LDNS_STATUS_SYNTAX_ORIGIN;
} else if (strncmp(line, "$TTL", 4) == 0 && isspace(line[4])) {
offset = 5;
while (isspace(line[offset])) {
offset++;
}
if (default_ttl) {
*default_ttl = ldns_str2period(line + offset, &endptr);
}
s = LDNS_STATUS_SYNTAX_TTL;
} else if (strncmp(line, "$INCLUDE", 8) == 0) {
s = LDNS_STATUS_SYNTAX_INCLUDE;
} else {
if (origin && *origin) {
s = ldns_rr_new_frm_str(&rr, (const char*) line, ttl, *origin, prev);
} else {
s = ldns_rr_new_frm_str(&rr, (const char*) line, ttl, NULL, prev);
}
}
LDNS_FREE(line);
if (s == LDNS_STATUS_OK) {
if (newrr) {
*newrr = rr;
} else {
/* Just testing if it would parse? */
ldns_rr_free(rr);
}
}
return s;
}
void
ldns_rr_set_owner(ldns_rr *rr, ldns_rdf *owner)
{
rr->_owner = owner;
}
void
ldns_rr_set_question(ldns_rr *rr, bool question)
{
rr->_rr_question = question;
}
void
ldns_rr_set_ttl(ldns_rr *rr, uint32_t ttl)
{
rr->_ttl = ttl;
}
void
ldns_rr_set_rd_count(ldns_rr *rr, size_t count)
{
rr->_rd_count = count;
}
void
ldns_rr_set_type(ldns_rr *rr, ldns_rr_type rr_type)
{
rr->_rr_type = rr_type;
}
void
ldns_rr_set_class(ldns_rr *rr, ldns_rr_class rr_class)
{
rr->_rr_class = rr_class;
}
ldns_rdf *
ldns_rr_set_rdf(ldns_rr *rr, const ldns_rdf *f, size_t position)
{
size_t rd_count;
ldns_rdf *pop;
rd_count = ldns_rr_rd_count(rr);
if (position < rd_count) {
/* dicard the old one */
pop = rr->_rdata_fields[position];
rr->_rdata_fields[position] = (ldns_rdf*)f;
return pop;
} else {
return NULL;
}
}
bool
ldns_rr_push_rdf(ldns_rr *rr, const ldns_rdf *f)
{
size_t rd_count;
ldns_rdf **rdata_fields;
rd_count = ldns_rr_rd_count(rr);
/* grow the array */
rdata_fields = LDNS_XREALLOC(
rr->_rdata_fields, ldns_rdf *, rd_count + 1);
if (!rdata_fields) {
return false;
}
/* add the new member */
rr->_rdata_fields = rdata_fields;
rr->_rdata_fields[rd_count] = (ldns_rdf*)f;
ldns_rr_set_rd_count(rr, rd_count + 1);
return true;
}
ldns_rdf *
ldns_rr_pop_rdf(ldns_rr *rr)
{
size_t rd_count;
ldns_rdf *pop;
ldns_rdf** newrd;
rd_count = ldns_rr_rd_count(rr);
if (rd_count == 0) {
return NULL;
}
pop = rr->_rdata_fields[rd_count - 1];
/* try to shrink the array */
if(rd_count > 1) {
newrd = LDNS_XREALLOC(
rr->_rdata_fields, ldns_rdf *, rd_count - 1);
if(newrd)
rr->_rdata_fields = newrd;
} else {
LDNS_FREE(rr->_rdata_fields);
}
ldns_rr_set_rd_count(rr, rd_count - 1);
return pop;
}
ldns_rdf *
ldns_rr_rdf(const ldns_rr *rr, size_t nr)
{
if (rr && nr < ldns_rr_rd_count(rr)) {
return rr->_rdata_fields[nr];
} else {
return NULL;
}
}
ldns_rdf *
ldns_rr_owner(const ldns_rr *rr)
{
return rr->_owner;
}
bool
ldns_rr_is_question(const ldns_rr *rr)
{
return rr->_rr_question;
}
uint32_t
ldns_rr_ttl(const ldns_rr *rr)
{
return rr->_ttl;
}
size_t
ldns_rr_rd_count(const ldns_rr *rr)
{
return rr->_rd_count;
}
ldns_rr_type
ldns_rr_get_type(const ldns_rr *rr)
{
return rr->_rr_type;
}
ldns_rr_class
ldns_rr_get_class(const ldns_rr *rr)
{
return rr->_rr_class;
}
/* rr_lists */
size_t
ldns_rr_list_rr_count(const ldns_rr_list *rr_list)
{
if (rr_list) {
return rr_list->_rr_count;
} else {
return 0;
}
}
ldns_rr *
ldns_rr_list_set_rr(ldns_rr_list *rr_list, const ldns_rr *r, size_t count)
{
ldns_rr *old;
if (count > ldns_rr_list_rr_count(rr_list)) {
return NULL;
}
old = ldns_rr_list_rr(rr_list, count);
/* overwrite old's pointer */
rr_list->_rrs[count] = (ldns_rr*)r;
return old;
}
void
ldns_rr_list_set_rr_count(ldns_rr_list *rr_list, size_t count)
{
assert(count <= rr_list->_rr_capacity);
rr_list->_rr_count = count;
}
ldns_rr *
ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr)
{
if (nr < ldns_rr_list_rr_count(rr_list)) {
return rr_list->_rrs[nr];
} else {
return NULL;
}
}
ldns_rr_list *
ldns_rr_list_new()
{
ldns_rr_list *rr_list = LDNS_MALLOC(ldns_rr_list);
if(!rr_list) return NULL;
rr_list->_rr_count = 0;
rr_list->_rr_capacity = 0;
rr_list->_rrs = NULL;
return rr_list;
}
void
ldns_rr_list_free(ldns_rr_list *rr_list)
{
if (rr_list) {
LDNS_FREE(rr_list->_rrs);
LDNS_FREE(rr_list);
}
}
void
ldns_rr_list_deep_free(ldns_rr_list *rr_list)
{
size_t i;
if (rr_list) {
for (i=0; i < ldns_rr_list_rr_count(rr_list); i++) {
ldns_rr_free(ldns_rr_list_rr(rr_list, i));
}
LDNS_FREE(rr_list->_rrs);
LDNS_FREE(rr_list);
}
}
/* add right to left. So we modify *left! */
bool
ldns_rr_list_cat(ldns_rr_list *left, ldns_rr_list *right)
{
size_t r_rr_count;
size_t i;
if (!left) {
return false;
}
if (right) {
r_rr_count = ldns_rr_list_rr_count(right);
} else {
r_rr_count = 0;
}
/* push right to left */
for(i = 0; i < r_rr_count; i++) {
ldns_rr_list_push_rr(left, ldns_rr_list_rr(right, i));
}
return true;
}
ldns_rr_list *
ldns_rr_list_cat_clone(ldns_rr_list *left, ldns_rr_list *right)
{
size_t l_rr_count;
size_t r_rr_count;
size_t i;
ldns_rr_list *cat;
if (left) {
l_rr_count = ldns_rr_list_rr_count(left);
} else {
return ldns_rr_list_clone(right);
}
if (right) {
r_rr_count = ldns_rr_list_rr_count(right);
} else {
r_rr_count = 0;
}
cat = ldns_rr_list_new();
if (!cat) {
return NULL;
}
/* left */
for(i = 0; i < l_rr_count; i++) {
ldns_rr_list_push_rr(cat,
ldns_rr_clone(ldns_rr_list_rr(left, i)));
}
/* right */
for(i = 0; i < r_rr_count; i++) {
ldns_rr_list_push_rr(cat,
ldns_rr_clone(ldns_rr_list_rr(right, i)));
}
return cat;
}
ldns_rr_list *
ldns_rr_list_subtype_by_rdf(ldns_rr_list *l, ldns_rdf *r, size_t pos)
{
size_t i;
ldns_rr_list *subtyped;
ldns_rdf *list_rdf;
subtyped = ldns_rr_list_new();
for(i = 0; i < ldns_rr_list_rr_count(l); i++) {
list_rdf = ldns_rr_rdf(
ldns_rr_list_rr(l, i),
pos);
if (!list_rdf) {
/* pos is too large or any other error */
ldns_rr_list_deep_free(subtyped);
return NULL;
}
if (ldns_rdf_compare(list_rdf, r) == 0) {
/* a match */
ldns_rr_list_push_rr(subtyped,
ldns_rr_clone(ldns_rr_list_rr(l, i)));
}
}
if (ldns_rr_list_rr_count(subtyped) > 0) {
return subtyped;
} else {
ldns_rr_list_free(subtyped);
return NULL;
}
}
bool
ldns_rr_list_push_rr(ldns_rr_list *rr_list, const ldns_rr *rr)
{
size_t rr_count;
size_t cap;
rr_count = ldns_rr_list_rr_count(rr_list);
cap = rr_list->_rr_capacity;
/* grow the array */
if(rr_count+1 > cap) {
ldns_rr **rrs;
if(cap == 0)
cap = LDNS_RRLIST_INIT; /* initial list size */
else cap *= 2;
rrs = LDNS_XREALLOC(rr_list->_rrs, ldns_rr *, cap);
if (!rrs) {
return false;
}
rr_list->_rrs = rrs;
rr_list->_rr_capacity = cap;
}
/* add the new member */
rr_list->_rrs[rr_count] = (ldns_rr*)rr;
ldns_rr_list_set_rr_count(rr_list, rr_count + 1);
return true;
}
bool
ldns_rr_list_push_rr_list(ldns_rr_list *rr_list, const ldns_rr_list *push_list)
{
size_t i;
for(i = 0; i < ldns_rr_list_rr_count(push_list); i++) {
if (!ldns_rr_list_push_rr(rr_list,
ldns_rr_list_rr(push_list, i))) {
return false;
}
}
return true;
}
ldns_rr *
ldns_rr_list_pop_rr(ldns_rr_list *rr_list)
{
size_t rr_count;
size_t cap;
ldns_rr *pop;
rr_count = ldns_rr_list_rr_count(rr_list);
if (rr_count == 0) {
return NULL;
}
cap = rr_list->_rr_capacity;
pop = ldns_rr_list_rr(rr_list, rr_count - 1);
/* shrink the array */
if(cap > LDNS_RRLIST_INIT && rr_count-1 <= cap/2) {
ldns_rr** a;
cap /= 2;
a = LDNS_XREALLOC(rr_list->_rrs, ldns_rr *, cap);
if(a) {
rr_list->_rrs = a;
rr_list->_rr_capacity = cap;
}
}
ldns_rr_list_set_rr_count(rr_list, rr_count - 1);
return pop;
}
ldns_rr_list *
ldns_rr_list_pop_rr_list(ldns_rr_list *rr_list, size_t howmany)
{
/* pop a number of rr's and put them in a rr_list */
ldns_rr_list *popped;
ldns_rr *p;
size_t i = howmany;
popped = ldns_rr_list_new();
if (!popped) {
return NULL;
}
while(i > 0 &&
(p = ldns_rr_list_pop_rr(rr_list)) != NULL) {
ldns_rr_list_push_rr(popped, p);
i--;
}
if (i == howmany) { /* so i <= 0 */
ldns_rr_list_free(popped);
return NULL;
} else {
return popped;
}
}
bool
ldns_rr_list_contains_rr(const ldns_rr_list *rr_list, ldns_rr *rr)
{
size_t i;
if (!rr_list || !rr || ldns_rr_list_rr_count(rr_list) == 0) {
return false;
}
for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) {
if (rr == ldns_rr_list_rr(rr_list, i)) {
return true;
} else if (ldns_rr_compare(rr, ldns_rr_list_rr(rr_list, i)) == 0) {
return true;
}
}
return false;
}
bool
ldns_is_rrset(ldns_rr_list *rr_list)
{
ldns_rr_type t;
ldns_rr_class c;
ldns_rdf *o;
ldns_rr *tmp;
size_t i;
if (!rr_list || ldns_rr_list_rr_count(rr_list) == 0) {
return false;
}
tmp = ldns_rr_list_rr(rr_list, 0);
t = ldns_rr_get_type(tmp);
c = ldns_rr_get_class(tmp);
o = ldns_rr_owner(tmp);
/* compare these with the rest of the rr_list, start with 1 */
for (i = 1; i < ldns_rr_list_rr_count(rr_list); i++) {
tmp = ldns_rr_list_rr(rr_list, i);
if (t != ldns_rr_get_type(tmp)) {
return false;
}
if (c != ldns_rr_get_class(tmp)) {
return false;
}
if (ldns_rdf_compare(o, ldns_rr_owner(tmp)) != 0) {
return false;
}
}
return true;
}
bool
ldns_rr_set_push_rr(ldns_rr_list *rr_list, ldns_rr *rr)
{
size_t rr_count;
size_t i;
ldns_rr *last;
assert(rr != NULL);
rr_count = ldns_rr_list_rr_count(rr_list);
if (rr_count == 0) {
/* nothing there, so checking it is
* not needed */
return ldns_rr_list_push_rr(rr_list, rr);
} else {
/* check with the final rr in the rr_list */
last = ldns_rr_list_rr(rr_list, rr_count - 1);
if (ldns_rr_get_class(last) != ldns_rr_get_class(rr)) {
return false;
}
if (ldns_rr_get_type(last) != ldns_rr_get_type(rr)) {
return false;
}
/* only check if not equal to RRSIG */
if (ldns_rr_get_type(rr) != LDNS_RR_TYPE_RRSIG) {
if (ldns_rr_ttl(last) != ldns_rr_ttl(rr)) {
return false;
}
}
if (ldns_rdf_compare(ldns_rr_owner(last),
ldns_rr_owner(rr)) != 0) {
return false;
}
/* ok, still alive - check if the rr already
* exists - if so, dont' add it */
for(i = 0; i < rr_count; i++) {
if(ldns_rr_compare(
ldns_rr_list_rr(rr_list, i), rr) == 0) {
return false;
}
}
/* it's safe, push it */
return ldns_rr_list_push_rr(rr_list, rr);
}
}
ldns_rr *
ldns_rr_set_pop_rr(ldns_rr_list *rr_list)
{
return ldns_rr_list_pop_rr(rr_list);
}
ldns_rr_list *
ldns_rr_list_pop_rrset(ldns_rr_list *rr_list)
{
ldns_rr_list *rrset;
ldns_rr *last_rr = NULL;
ldns_rr *next_rr;
if (!rr_list) {
return NULL;
}
rrset = ldns_rr_list_new();
if (!last_rr) {
last_rr = ldns_rr_list_pop_rr(rr_list);
if (!last_rr) {
ldns_rr_list_free(rrset);
return NULL;
} else {
ldns_rr_list_push_rr(rrset, last_rr);
}
}
if (ldns_rr_list_rr_count(rr_list) > 0) {
next_rr = ldns_rr_list_rr(rr_list, ldns_rr_list_rr_count(rr_list) - 1);
} else {
next_rr = NULL;
}
while (next_rr) {
if (
ldns_rdf_compare(ldns_rr_owner(next_rr),
ldns_rr_owner(last_rr)) == 0
&&
ldns_rr_get_type(next_rr) == ldns_rr_get_type(last_rr)
&&
ldns_rr_get_class(next_rr) == ldns_rr_get_class(last_rr)
) {
ldns_rr_list_push_rr(rrset, ldns_rr_list_pop_rr(rr_list));
if (ldns_rr_list_rr_count(rr_list) > 0) {
last_rr = next_rr;
next_rr = ldns_rr_list_rr(rr_list, ldns_rr_list_rr_count(rr_list) - 1);
} else {
next_rr = NULL;
}
} else {
next_rr = NULL;
}
}
return rrset;
}
ldns_rr *
ldns_rr_clone(const ldns_rr *rr)
{
size_t i;
ldns_rr *new_rr;
if (!rr) {
return NULL;
}
new_rr = ldns_rr_new();
if (!new_rr) {
return NULL;
}
if (ldns_rr_owner(rr)) {
ldns_rr_set_owner(new_rr, ldns_rdf_clone(ldns_rr_owner(rr)));
}
ldns_rr_set_ttl(new_rr, ldns_rr_ttl(rr));
ldns_rr_set_type(new_rr, ldns_rr_get_type(rr));
ldns_rr_set_class(new_rr, ldns_rr_get_class(rr));
ldns_rr_set_question(new_rr, ldns_rr_is_question(rr));
for (i = 0; i < ldns_rr_rd_count(rr); i++) {
if (ldns_rr_rdf(rr,i)) {
ldns_rr_push_rdf(new_rr, ldns_rdf_clone(ldns_rr_rdf(rr, i)));
}
}
return new_rr;
}
ldns_rr_list *
ldns_rr_list_clone(const ldns_rr_list *rrlist)
{
size_t i;
ldns_rr_list *new_list;
ldns_rr *r;
if (!rrlist) {
return NULL;
}
new_list = ldns_rr_list_new();
if (!new_list) {
return NULL;
}
for (i = 0; i < ldns_rr_list_rr_count(rrlist); i++) {
r = ldns_rr_clone(
ldns_rr_list_rr(rrlist, i)
);
if (!r) {
/* huh, failure in cloning */
ldns_rr_list_deep_free(new_list);
return NULL;
}
ldns_rr_list_push_rr(new_list, r);
}
return new_list;
}
int
qsort_rr_compare(const void *a, const void *b)
{
const ldns_rr *rr1 = * (const ldns_rr **) a;
const ldns_rr *rr2 = * (const ldns_rr **) b;
if (rr1 == NULL && rr2 == NULL) {
return 0;
}
if (rr1 == NULL) {
return -1;
}
if (rr2 == NULL) {
return 1;
}
return ldns_rr_compare(rr1, rr2);
}
int
qsort_schwartz_rr_compare(const void *a, const void *b)
{
int result = 0;
ldns_rr *rr1, *rr2;
ldns_buffer *rr1_buf, *rr2_buf;
struct ldns_schwartzian_compare_struct *sa = *(struct ldns_schwartzian_compare_struct **) a;
struct ldns_schwartzian_compare_struct *sb = *(struct ldns_schwartzian_compare_struct **) b;
/* if we are doing 2wire, we need to do lowercasing on the dname (and maybe on the rdata)
* this must be done for comparison only, so we need to have a temp var for both buffers,
* which is only used when the transformed object value isn't there yet
*/
ldns_rr *canonical_a, *canonical_b;
rr1 = (ldns_rr *) sa->original_object;
rr2 = (ldns_rr *) sb->original_object;
result = ldns_rr_compare_no_rdata(rr1, rr2);
if (result == 0) {
if (!sa->transformed_object) {
canonical_a = ldns_rr_clone(sa->original_object);
ldns_rr2canonical(canonical_a);
sa->transformed_object = ldns_buffer_new(ldns_rr_uncompressed_size(canonical_a));
if (ldns_rr2buffer_wire(sa->transformed_object, canonical_a, LDNS_SECTION_ANY) != LDNS_STATUS_OK) {
ldns_buffer_free((ldns_buffer *)sa->transformed_object);
sa->transformed_object = NULL;
ldns_rr_free(canonical_a);
return 0;
}
ldns_rr_free(canonical_a);
}
if (!sb->transformed_object) {
canonical_b = ldns_rr_clone(sb->original_object);
ldns_rr2canonical(canonical_b);
sb->transformed_object = ldns_buffer_new(ldns_rr_uncompressed_size(canonical_b));
if (ldns_rr2buffer_wire(sb->transformed_object, canonical_b, LDNS_SECTION_ANY) != LDNS_STATUS_OK) {
ldns_buffer_free((ldns_buffer *)sa->transformed_object);
ldns_buffer_free((ldns_buffer *)sb->transformed_object);
sa->transformed_object = NULL;
sb->transformed_object = NULL;
ldns_rr_free(canonical_b);
return 0;
}
ldns_rr_free(canonical_b);
}
rr1_buf = (ldns_buffer *) sa->transformed_object;
rr2_buf = (ldns_buffer *) sb->transformed_object;
result = ldns_rr_compare_wire(rr1_buf, rr2_buf);
}
return result;
}
void
ldns_rr_list_sort(ldns_rr_list *unsorted)
{
struct ldns_schwartzian_compare_struct **sortables;
size_t item_count;
size_t i;
if (unsorted) {
item_count = ldns_rr_list_rr_count(unsorted);
sortables = LDNS_XMALLOC(struct ldns_schwartzian_compare_struct *,
item_count);
if(!sortables) return; /* no way to return error */
for (i = 0; i < item_count; i++) {
sortables[i] = LDNS_XMALLOC(struct ldns_schwartzian_compare_struct, 1);
if(!sortables[i]) {
/* free the allocated parts */
while(i>0) {
i--;
LDNS_FREE(sortables[i]);
}
/* no way to return error */
LDNS_FREE(sortables);
return;
}
sortables[i]->original_object = ldns_rr_list_rr(unsorted, i);
sortables[i]->transformed_object = NULL;
}
qsort(sortables,
item_count,
sizeof(struct ldns_schwartzian_compare_struct *),
qsort_schwartz_rr_compare);
for (i = 0; i < item_count; i++) {
unsorted->_rrs[i] = sortables[i]->original_object;
if (sortables[i]->transformed_object) {
ldns_buffer_free(sortables[i]->transformed_object);
}
LDNS_FREE(sortables[i]);
}
LDNS_FREE(sortables);
}
}
int
ldns_rr_compare_no_rdata(const ldns_rr *rr1, const ldns_rr *rr2)
{
size_t rr1_len;
size_t rr2_len;
size_t offset;
assert(rr1 != NULL);
assert(rr2 != NULL);
rr1_len = ldns_rr_uncompressed_size(rr1);
rr2_len = ldns_rr_uncompressed_size(rr2);
if (ldns_dname_compare(ldns_rr_owner(rr1), ldns_rr_owner(rr2)) < 0) {
return -1;
} else if (ldns_dname_compare(ldns_rr_owner(rr1), ldns_rr_owner(rr2)) > 0) {
return 1;
}
/* should return -1 if rr1 comes before rr2, so need to do rr1 - rr2, not rr2 - rr1 */
if (ldns_rr_get_class(rr1) != ldns_rr_get_class(rr2)) {
return ldns_rr_get_class(rr1) - ldns_rr_get_class(rr2);
}
/* should return -1 if rr1 comes before rr2, so need to do rr1 - rr2, not rr2 - rr1 */
if (ldns_rr_get_type(rr1) != ldns_rr_get_type(rr2)) {
return ldns_rr_get_type(rr1) - ldns_rr_get_type(rr2);
}
/* offset is the owername length + ttl + type + class + rdlen == start of wire format rdata */
offset = ldns_rdf_size(ldns_rr_owner(rr1)) + 4 + 2 + 2 + 2;
/* if either record doesn't have any RDATA... */
if (offset > rr1_len || offset > rr2_len) {
if (rr1_len == rr2_len) {
return 0;
}
return ((int) rr2_len - (int) rr1_len);
}
return 0;
}
int ldns_rr_compare_wire(ldns_buffer *rr1_buf, ldns_buffer *rr2_buf)
{
size_t rr1_len, rr2_len, min_len, i, offset;
rr1_len = ldns_buffer_capacity(rr1_buf);
rr2_len = ldns_buffer_capacity(rr2_buf);
/* jump past dname (checked in earlier part)
* and especially past TTL */
offset = 0;
while (offset < rr1_len && *ldns_buffer_at(rr1_buf, offset) != 0) {
offset += *ldns_buffer_at(rr1_buf, offset) + 1;
}
/* jump to rdata section (PAST the rdata length field, otherwise
rrs with different lengths might be sorted erroneously */
offset += 11;
min_len = (rr1_len < rr2_len) ? rr1_len : rr2_len;
/* Compare RRs RDATA byte for byte. */
for(i = offset; i < min_len; i++) {
if (*ldns_buffer_at(rr1_buf,i) < *ldns_buffer_at(rr2_buf,i)) {
return -1;
} else if (*ldns_buffer_at(rr1_buf,i) > *ldns_buffer_at(rr2_buf,i)) {
return +1;
}
}
/* If both RDATAs are the same up to min_len, then the shorter one sorts first. */
if (rr1_len < rr2_len) {
return -1;
} else if (rr1_len > rr2_len) {
return +1;
}
/* The RDATAs are equal. */
return 0;
}
int
ldns_rr_compare(const ldns_rr *rr1, const ldns_rr *rr2)
{
int result;
size_t rr1_len, rr2_len;
ldns_buffer *rr1_buf;
ldns_buffer *rr2_buf;
result = ldns_rr_compare_no_rdata(rr1, rr2);
if (result == 0) {
rr1_len = ldns_rr_uncompressed_size(rr1);
rr2_len = ldns_rr_uncompressed_size(rr2);
rr1_buf = ldns_buffer_new(rr1_len);
rr2_buf = ldns_buffer_new(rr2_len);
if (ldns_rr2buffer_wire_canonical(rr1_buf,
rr1,
LDNS_SECTION_ANY)
!= LDNS_STATUS_OK) {
ldns_buffer_free(rr1_buf);
ldns_buffer_free(rr2_buf);
return 0;
}
if (ldns_rr2buffer_wire_canonical(rr2_buf,
rr2,
LDNS_SECTION_ANY)
!= LDNS_STATUS_OK) {
ldns_buffer_free(rr1_buf);
ldns_buffer_free(rr2_buf);
return 0;
}
result = ldns_rr_compare_wire(rr1_buf, rr2_buf);
ldns_buffer_free(rr1_buf);
ldns_buffer_free(rr2_buf);
}
return result;
}
/* convert dnskey to a ds with the given algorithm,
* then compare the result with the given ds */
static int
ldns_rr_compare_ds_dnskey(ldns_rr *ds,
ldns_rr *dnskey)
{
ldns_rr *ds_gen;
bool result = false;
ldns_hash algo;
if (!dnskey || !ds ||
ldns_rr_get_type(ds) != LDNS_RR_TYPE_DS ||
ldns_rr_get_type(dnskey) != LDNS_RR_TYPE_DNSKEY) {
return false;
}
if (ldns_rr_rdf(ds, 2) == NULL) {
return false;
}
algo = ldns_rdf2native_int8(ldns_rr_rdf(ds, 2));
ds_gen = ldns_key_rr2ds(dnskey, algo);
if (ds_gen) {
result = ldns_rr_compare(ds, ds_gen) == 0;
ldns_rr_free(ds_gen);
}
return result;
}
bool
ldns_rr_compare_ds(const ldns_rr *orr1, const ldns_rr *orr2)
{
bool result;
ldns_rr *rr1 = ldns_rr_clone(orr1);
ldns_rr *rr2 = ldns_rr_clone(orr2);
/* set ttls to zero */
ldns_rr_set_ttl(rr1, 0);
ldns_rr_set_ttl(rr2, 0);
if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_DS &&
ldns_rr_get_type(rr2) == LDNS_RR_TYPE_DNSKEY) {
result = ldns_rr_compare_ds_dnskey(rr1, rr2);
} else if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_DNSKEY &&
ldns_rr_get_type(rr2) == LDNS_RR_TYPE_DS) {
result = ldns_rr_compare_ds_dnskey(rr2, rr1);
} else {
result = (ldns_rr_compare(rr1, rr2) == 0);
}
ldns_rr_free(rr1);
ldns_rr_free(rr2);
return result;
}
int
ldns_rr_list_compare(const ldns_rr_list *rrl1, const ldns_rr_list *rrl2)
{
size_t i = 0;
int rr_cmp;
assert(rrl1 != NULL);
assert(rrl2 != NULL);
for (i = 0; i < ldns_rr_list_rr_count(rrl1) && i < ldns_rr_list_rr_count(rrl2); i++) {
rr_cmp = ldns_rr_compare(ldns_rr_list_rr(rrl1, i), ldns_rr_list_rr(rrl2, i));
if (rr_cmp != 0) {
return rr_cmp;
}
}
if (i == ldns_rr_list_rr_count(rrl1) &&
i != ldns_rr_list_rr_count(rrl2)) {
return 1;
} else if (i == ldns_rr_list_rr_count(rrl2) &&
i != ldns_rr_list_rr_count(rrl1)) {
return -1;
} else {
return 0;
}
}
size_t
ldns_rr_uncompressed_size(const ldns_rr *r)
{
size_t rrsize;
size_t i;
rrsize = 0;
/* add all the rdf sizes */
for(i = 0; i < ldns_rr_rd_count(r); i++) {
rrsize += ldns_rdf_size(ldns_rr_rdf(r, i));
}
/* ownername */
rrsize += ldns_rdf_size(ldns_rr_owner(r));
rrsize += LDNS_RR_OVERHEAD;
return rrsize;
}
void
ldns_rr2canonical(ldns_rr *rr)
{
uint16_t i;
if (!rr) {
return;
}
ldns_dname2canonical(ldns_rr_owner(rr));
/*
* lowercase the rdata dnames if the rr type is one
* of the list in chapter 7 of RFC3597
* Also added RRSIG, because a "Signer's Name" should be canonicalized
* too. See dnssec-bis-updates-16. We can add it to this list because
* the "Signer's Name" is the only dname type rdata field in a RRSIG.
*/
switch(ldns_rr_get_type(rr)) {
case LDNS_RR_TYPE_NS:
case LDNS_RR_TYPE_MD:
case LDNS_RR_TYPE_MF:
case LDNS_RR_TYPE_CNAME:
case LDNS_RR_TYPE_SOA:
case LDNS_RR_TYPE_MB:
case LDNS_RR_TYPE_MG:
case LDNS_RR_TYPE_MR:
case LDNS_RR_TYPE_PTR:
case LDNS_RR_TYPE_MINFO:
case LDNS_RR_TYPE_MX:
case LDNS_RR_TYPE_RP:
case LDNS_RR_TYPE_AFSDB:
case LDNS_RR_TYPE_RT:
case LDNS_RR_TYPE_SIG:
case LDNS_RR_TYPE_PX:
case LDNS_RR_TYPE_NXT:
case LDNS_RR_TYPE_NAPTR:
case LDNS_RR_TYPE_KX:
case LDNS_RR_TYPE_SRV:
case LDNS_RR_TYPE_DNAME:
case LDNS_RR_TYPE_A6:
case LDNS_RR_TYPE_RRSIG:
for (i = 0; i < ldns_rr_rd_count(rr); i++) {
ldns_dname2canonical(ldns_rr_rdf(rr, i));
}
return;
default:
/* do nothing */
return;
}
}
void
ldns_rr_list2canonical(ldns_rr_list *rr_list)
{
size_t i;
for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) {
ldns_rr2canonical(ldns_rr_list_rr(rr_list, i));
}
}
uint8_t
ldns_rr_label_count(ldns_rr *rr)
{
if (!rr) {
return 0;
}
return ldns_dname_label_count(
ldns_rr_owner(rr));
}
/** \cond */
static const ldns_rdf_type type_0_wireformat[] = { LDNS_RDF_TYPE_UNKNOWN };
static const ldns_rdf_type type_a_wireformat[] = { LDNS_RDF_TYPE_A };
static const ldns_rdf_type type_ns_wireformat[] = { LDNS_RDF_TYPE_DNAME };
static const ldns_rdf_type type_md_wireformat[] = { LDNS_RDF_TYPE_DNAME };
static const ldns_rdf_type type_mf_wireformat[] = { LDNS_RDF_TYPE_DNAME };
static const ldns_rdf_type type_cname_wireformat[] = { LDNS_RDF_TYPE_DNAME };
static const ldns_rdf_type type_soa_wireformat[] = {
LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_INT32,
LDNS_RDF_TYPE_PERIOD, LDNS_RDF_TYPE_PERIOD, LDNS_RDF_TYPE_PERIOD,
LDNS_RDF_TYPE_PERIOD
};
static const ldns_rdf_type type_mb_wireformat[] = { LDNS_RDF_TYPE_DNAME };
static const ldns_rdf_type type_mg_wireformat[] = { LDNS_RDF_TYPE_DNAME };
static const ldns_rdf_type type_mr_wireformat[] = { LDNS_RDF_TYPE_DNAME };
static const ldns_rdf_type type_wks_wireformat[] = {
LDNS_RDF_TYPE_A, LDNS_RDF_TYPE_WKS
};
static const ldns_rdf_type type_ptr_wireformat[] = { LDNS_RDF_TYPE_DNAME };
static const ldns_rdf_type type_hinfo_wireformat[] = {
LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR
};
static const ldns_rdf_type type_minfo_wireformat[] = {
LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME
};
static const ldns_rdf_type type_mx_wireformat[] = {
LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME
};
static const ldns_rdf_type type_rp_wireformat[] = {
LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME
};
static const ldns_rdf_type type_afsdb_wireformat[] = {
LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME
};
static const ldns_rdf_type type_x25_wireformat[] = { LDNS_RDF_TYPE_STR };
static const ldns_rdf_type type_isdn_wireformat[] = {
LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR
};
static const ldns_rdf_type type_rt_wireformat[] = {
LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME
};
static const ldns_rdf_type type_nsap_wireformat[] = {
LDNS_RDF_TYPE_NSAP
};
static const ldns_rdf_type type_nsap_ptr_wireformat[] = {
LDNS_RDF_TYPE_STR
};
static const ldns_rdf_type type_sig_wireformat[] = {
LDNS_RDF_TYPE_TYPE, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT32,
LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_INT16,
LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_B64
};
static const ldns_rdf_type type_key_wireformat[] = {
LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_B64
};
static const ldns_rdf_type type_px_wireformat[] = {
LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME
};
static const ldns_rdf_type type_gpos_wireformat[] = {
LDNS_RDF_TYPE_STR,
LDNS_RDF_TYPE_STR,
LDNS_RDF_TYPE_STR
};
static const ldns_rdf_type type_aaaa_wireformat[] = { LDNS_RDF_TYPE_AAAA };
static const ldns_rdf_type type_loc_wireformat[] = { LDNS_RDF_TYPE_LOC };
static const ldns_rdf_type type_nxt_wireformat[] = {
LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_UNKNOWN
};
static const ldns_rdf_type type_eid_wireformat[] = {
LDNS_RDF_TYPE_HEX
};
static const ldns_rdf_type type_nimloc_wireformat[] = {
LDNS_RDF_TYPE_HEX
};
static const ldns_rdf_type type_srv_wireformat[] = {
LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME
};
static const ldns_rdf_type type_atma_wireformat[] = {
LDNS_RDF_TYPE_ATMA
};
static const ldns_rdf_type type_naptr_wireformat[] = {
LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_DNAME
};
static const ldns_rdf_type type_kx_wireformat[] = {
LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME
};
static const ldns_rdf_type type_cert_wireformat[] = {
LDNS_RDF_TYPE_CERT_ALG, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_B64
};
static const ldns_rdf_type type_a6_wireformat[] = { LDNS_RDF_TYPE_UNKNOWN };
static const ldns_rdf_type type_dname_wireformat[] = { LDNS_RDF_TYPE_DNAME };
static const ldns_rdf_type type_sink_wireformat[] = { LDNS_RDF_TYPE_INT8,
LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_B64
};
static const ldns_rdf_type type_apl_wireformat[] = {
LDNS_RDF_TYPE_APL
};
static const ldns_rdf_type type_ds_wireformat[] = {
LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_HEX
};
static const ldns_rdf_type type_sshfp_wireformat[] = {
LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_HEX
};
static const ldns_rdf_type type_ipseckey_wireformat[] = {
LDNS_RDF_TYPE_IPSECKEY
};
static const ldns_rdf_type type_rrsig_wireformat[] = {
LDNS_RDF_TYPE_TYPE, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT32,
LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_B64
};
static const ldns_rdf_type type_nsec_wireformat[] = {
LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_NSEC
};
static const ldns_rdf_type type_dhcid_wireformat[] = {
LDNS_RDF_TYPE_B64
};
static const ldns_rdf_type type_talink_wireformat[] = {
LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME
};
/* nsec3 is some vars, followed by same type of data of nsec */
static const ldns_rdf_type type_nsec3_wireformat[] = {
/* LDNS_RDF_TYPE_NSEC3_VARS, LDNS_RDF_TYPE_NSEC3_NEXT_OWNER, LDNS_RDF_TYPE_NSEC*/
LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_NSEC3_SALT, LDNS_RDF_TYPE_NSEC3_NEXT_OWNER, LDNS_RDF_TYPE_NSEC
};
static const ldns_rdf_type type_nsec3param_wireformat[] = {
/* LDNS_RDF_TYPE_NSEC3_PARAMS_VARS*/
LDNS_RDF_TYPE_INT8,
LDNS_RDF_TYPE_INT8,
LDNS_RDF_TYPE_INT16,
LDNS_RDF_TYPE_NSEC3_SALT
};
static const ldns_rdf_type type_dnskey_wireformat[] = {
LDNS_RDF_TYPE_INT16,
LDNS_RDF_TYPE_INT8,
LDNS_RDF_TYPE_ALG,
LDNS_RDF_TYPE_B64
};
static const ldns_rdf_type type_tsig_wireformat[] = {
LDNS_RDF_TYPE_DNAME,
LDNS_RDF_TYPE_TSIGTIME,
LDNS_RDF_TYPE_INT16,
LDNS_RDF_TYPE_INT16_DATA,
LDNS_RDF_TYPE_INT16,
LDNS_RDF_TYPE_INT16,
LDNS_RDF_TYPE_INT16_DATA
};
static const ldns_rdf_type type_tlsa_wireformat[] = {
LDNS_RDF_TYPE_INT8,
LDNS_RDF_TYPE_INT8,
LDNS_RDF_TYPE_INT8,
LDNS_RDF_TYPE_HEX
};
/** \endcond */
/** \cond */
/* All RR's defined in 1035 are well known and can thus
* be compressed. See RFC3597. These RR's are:
* CNAME HINFO MB MD MF MG MINFO MR MX NULL NS PTR SOA TXT
*/
static ldns_rr_descriptor rdata_field_descriptors[] = {
/* 0 */
{ 0, NULL, 0, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 1 */
{LDNS_RR_TYPE_A, "A", 1, 1, type_a_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 2 */
{LDNS_RR_TYPE_NS, "NS", 1, 1, type_ns_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
/* 3 */
{LDNS_RR_TYPE_MD, "MD", 1, 1, type_md_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
/* 4 */
{LDNS_RR_TYPE_MF, "MF", 1, 1, type_mf_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
/* 5 */
{LDNS_RR_TYPE_CNAME, "CNAME", 1, 1, type_cname_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
/* 6 */
{LDNS_RR_TYPE_SOA, "SOA", 7, 7, type_soa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 2 },
/* 7 */
{LDNS_RR_TYPE_MB, "MB", 1, 1, type_mb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
/* 8 */
{LDNS_RR_TYPE_MG, "MG", 1, 1, type_mg_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
/* 9 */
{LDNS_RR_TYPE_MR, "MR", 1, 1, type_mr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
/* 10 */
{LDNS_RR_TYPE_NULL, "NULL", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 11 */
{LDNS_RR_TYPE_WKS, "WKS", 2, 2, type_wks_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 12 */
{LDNS_RR_TYPE_PTR, "PTR", 1, 1, type_ptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
/* 13 */
{LDNS_RR_TYPE_HINFO, "HINFO", 2, 2, type_hinfo_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 14 */
{LDNS_RR_TYPE_MINFO, "MINFO", 2, 2, type_minfo_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 2 },
/* 15 */
{LDNS_RR_TYPE_MX, "MX", 2, 2, type_mx_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
/* 16 */
{LDNS_RR_TYPE_TXT, "TXT", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
/* 17 */
{LDNS_RR_TYPE_RP, "RP", 2, 2, type_rp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 },
/* 18 */
{LDNS_RR_TYPE_AFSDB, "AFSDB", 2, 2, type_afsdb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
/* 19 */
{LDNS_RR_TYPE_X25, "X25", 1, 1, type_x25_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 20 */
{LDNS_RR_TYPE_ISDN, "ISDN", 1, 2, type_isdn_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 21 */
{LDNS_RR_TYPE_RT, "RT", 2, 2, type_rt_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
/* 22 */
{LDNS_RR_TYPE_NSAP, "NSAP", 1, 1, type_nsap_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 23 */
{LDNS_RR_TYPE_NSAP_PTR, "NSAP-PTR", 1, 1, type_nsap_ptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 24 */
{LDNS_RR_TYPE_SIG, "SIG", 9, 9, type_sig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
/* 25 */
{LDNS_RR_TYPE_KEY, "KEY", 4, 4, type_key_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 26 */
{LDNS_RR_TYPE_PX, "PX", 3, 3, type_px_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 },
/* 27 */
{LDNS_RR_TYPE_GPOS, "GPOS", 1, 1, type_gpos_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 28 */
{LDNS_RR_TYPE_AAAA, "AAAA", 1, 1, type_aaaa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 29 */
{LDNS_RR_TYPE_LOC, "LOC", 1, 1, type_loc_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 30 */
{LDNS_RR_TYPE_NXT, "NXT", 2, 2, type_nxt_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
/* 31 */
{LDNS_RR_TYPE_EID, "EID", 1, 1, type_eid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 32 */
{LDNS_RR_TYPE_NIMLOC, "NIMLOC", 1, 1, type_nimloc_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 33 */
{LDNS_RR_TYPE_SRV, "SRV", 4, 4, type_srv_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
/* 34 */
{LDNS_RR_TYPE_ATMA, "ATMA", 1, 1, type_atma_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 35 */
{LDNS_RR_TYPE_NAPTR, "NAPTR", 6, 6, type_naptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
/* 36 */
{LDNS_RR_TYPE_KX, "KX", 2, 2, type_kx_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
/* 37 */
{LDNS_RR_TYPE_CERT, "CERT", 4, 4, type_cert_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 38 */
{LDNS_RR_TYPE_A6, "A6", 1, 1, type_a6_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 39 */
{LDNS_RR_TYPE_DNAME, "DNAME", 1, 1, type_dname_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
/* 40 */
{LDNS_RR_TYPE_SINK, "SINK", 1, 1, type_sink_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 41 */
{LDNS_RR_TYPE_OPT, "OPT", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 42 */
{LDNS_RR_TYPE_APL, "APL", 0, 0, type_apl_wireformat, LDNS_RDF_TYPE_APL, LDNS_RR_NO_COMPRESS, 0 },
/* 43 */
{LDNS_RR_TYPE_DS, "DS", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 44 */
{LDNS_RR_TYPE_SSHFP, "SSHFP", 3, 3, type_sshfp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 45 */
{LDNS_RR_TYPE_IPSECKEY, "IPSECKEY", 1, 1, type_ipseckey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 46 */
{LDNS_RR_TYPE_RRSIG, "RRSIG", 9, 9, type_rrsig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
/* 47 */
{LDNS_RR_TYPE_NSEC, "NSEC", 1, 2, type_nsec_wireformat, LDNS_RDF_TYPE_NSEC, LDNS_RR_NO_COMPRESS, 1 },
/* 48 */
{LDNS_RR_TYPE_DNSKEY, "DNSKEY", 4, 4, type_dnskey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 49 */
{LDNS_RR_TYPE_DHCID, "DHCID", 1, 1, type_dhcid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 50 */
{LDNS_RR_TYPE_NSEC3, "NSEC3", 5, 6, type_nsec3_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 51 */
{LDNS_RR_TYPE_NSEC3PARAM, "NSEC3PARAM", 4, 4, type_nsec3param_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 52 */
{LDNS_RR_TYPE_TLSA, "TLSA", 4, 4, type_tlsa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE53", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE54", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE55", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE56", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE57", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* 58 */
{LDNS_RR_TYPE_TALINK, "TALINK", 2, 2, type_talink_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 },
{LDNS_RR_TYPE_NULL, "TYPE59", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE60", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE61", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE62", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE63", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE64", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE65", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE66", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE67", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE68", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE69", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE70", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE71", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE72", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE73", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE74", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE75", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE76", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE77", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE78", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE79", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE80", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE81", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE82", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE83", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE84", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE85", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE86", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE87", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE88", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE89", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE90", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE91", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE92", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE93", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE94", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE95", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE96", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE97", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE98", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_SPF, "SPF", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE100", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE101", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE102", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE103", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE104", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE105", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE106", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE107", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE108", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE109", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE110", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE111", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE112", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE113", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE114", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE115", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE116", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE117", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE118", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE119", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE120", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE121", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE122", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE123", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE124", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE125", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE126", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE127", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE128", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE129", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE130", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE131", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE132", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE133", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE134", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE135", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE136", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE137", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE138", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE139", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE140", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE141", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE142", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE143", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE144", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE145", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE146", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE147", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE148", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE149", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE150", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE151", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE152", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE153", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE154", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE155", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE156", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE157", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE158", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE159", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE160", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE161", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE162", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE163", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE164", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE165", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE166", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE167", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE168", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE169", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE170", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE171", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE172", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE173", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE174", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE175", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE176", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE177", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE178", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE179", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE180", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE181", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE182", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE183", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE184", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE185", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE186", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE187", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE188", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE189", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE190", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE191", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE192", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE193", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE194", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE195", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE196", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE197", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE198", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE199", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE200", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE201", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE202", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE203", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE204", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE205", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE206", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE207", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE208", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE209", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE210", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE211", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE212", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE213", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE214", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE215", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE216", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE217", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE218", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE219", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE220", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE221", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE222", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE223", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE224", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE225", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE226", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE227", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE228", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE229", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE230", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE231", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE232", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE233", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE234", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE235", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE236", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE237", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE238", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE239", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE240", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE241", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE242", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE243", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE244", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE245", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE246", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE247", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE248", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE249", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* LDNS_RDF_TYPE_INT16_DATA essentially takes two fields (length and data) and
* makes them into one. So, while in rfc 2845 is specified that a TSIG may have
* 8 or 9 rdata fields, by this implementation, the min/max are 7 each.
*/
{LDNS_RR_TYPE_TSIG, "TSIG", 7, 7, type_tsig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
/* split in array, no longer contiguous */
{LDNS_RR_TYPE_DLV, "DLV", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }
};
/** \endcond */
/**
* \def LDNS_RDATA_FIELD_DESCRIPTORS_COUNT
* computes the number of rdata fields
*/
#define LDNS_RDATA_FIELD_DESCRIPTORS_COUNT \
(sizeof(rdata_field_descriptors)/sizeof(rdata_field_descriptors[0]))
const ldns_rr_descriptor *
ldns_rr_descript(uint16_t type)
{
size_t i;
if (type <= LDNS_RDATA_FIELD_DESCRIPTORS_COMMON) {
return &rdata_field_descriptors[type];
} else {
/* because not all array index equals type code */
for (i = LDNS_RDATA_FIELD_DESCRIPTORS_COMMON;
i < LDNS_RDATA_FIELD_DESCRIPTORS_COUNT;
i++) {
if (rdata_field_descriptors[i]._type == type) {
return &rdata_field_descriptors[i];
}
}
return &rdata_field_descriptors[0];
}
}
size_t
ldns_rr_descriptor_minimum(const ldns_rr_descriptor *descriptor)
{
if (descriptor) {
return descriptor->_minimum;
} else {
return 0;
}
}
size_t
ldns_rr_descriptor_maximum(const ldns_rr_descriptor *descriptor)
{
if (descriptor) {
if (descriptor->_variable != LDNS_RDF_TYPE_NONE) {
/* Should really be SIZE_MAX... bad FreeBSD. */
return UINT_MAX;
} else {
return descriptor->_maximum;
}
} else {
return 0;
}
}
ldns_rdf_type
ldns_rr_descriptor_field_type(const ldns_rr_descriptor *descriptor,
size_t index)
{
assert(descriptor != NULL);
assert(index < descriptor->_maximum
|| descriptor->_variable != LDNS_RDF_TYPE_NONE);
if (index < descriptor->_maximum) {
return descriptor->_wireformat[index];
} else {
return descriptor->_variable;
}
}
ldns_rr_type
ldns_get_rr_type_by_name(const char *name)
{
unsigned int i;
const char *desc_name;
const ldns_rr_descriptor *desc;
/* TYPEXX representation */
if (strlen(name) > 4 && strncasecmp(name, "TYPE", 4) == 0) {
return atoi(name + 4);
}
/* Normal types */
for (i = 0; i < (unsigned int) LDNS_RDATA_FIELD_DESCRIPTORS_COUNT; i++) {
desc = &rdata_field_descriptors[i];
desc_name = desc->_name;
if(desc_name &&
strlen(name) == strlen(desc_name) &&
strncasecmp(name, desc_name, strlen(desc_name)) == 0) {
/* because not all array index equals type code */
return desc->_type;
}
}
/* special cases for query types */
if (strlen(name) == 4 && strncasecmp(name, "IXFR", 4) == 0) {
return 251;
} else if (strlen(name) == 4 && strncasecmp(name, "AXFR", 4) == 0) {
return 252;
} else if (strlen(name) == 5 && strncasecmp(name, "MAILB", 5) == 0) {
return 253;
} else if (strlen(name) == 5 && strncasecmp(name, "MAILA", 5) == 0) {
return 254;
} else if (strlen(name) == 3 && strncasecmp(name, "ANY", 3) == 0) {
return 255;
}
return 0;
}
ldns_rr_class
ldns_get_rr_class_by_name(const char *name)
{
ldns_lookup_table *lt;
/* CLASSXX representation */
if (strlen(name) > 5 && strncasecmp(name, "CLASS", 5) == 0) {
return atoi(name + 5);
}
/* Normal types */
lt = ldns_lookup_by_name(ldns_rr_classes, name);
if (lt) {
return lt->id;
}
return 0;
}
ldns_rr_type
ldns_rdf2rr_type(const ldns_rdf *rd)
{
ldns_rr_type r;
if (!rd) {
return 0;
}
if (ldns_rdf_get_type(rd) != LDNS_RDF_TYPE_TYPE) {
return 0;
}
r = (ldns_rr_type) ldns_rdf2native_int16(rd);
return r;
}
ldns_rr_type
ldns_rr_list_type(const ldns_rr_list *rr_list)
{
if (rr_list && ldns_rr_list_rr_count(rr_list) > 0) {
return ldns_rr_get_type(ldns_rr_list_rr(rr_list, 0));
} else {
return 0;
}
}
ldns_rdf *
ldns_rr_list_owner(const ldns_rr_list *rr_list)
{
if (rr_list && ldns_rr_list_rr_count(rr_list) > 0) {
return ldns_rr_owner(ldns_rr_list_rr(rr_list, 0));
} else {
return NULL;
}
}
|