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 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581
|
/******************************************************************************
* ldns_rr.i: LDNS resource records (RR), RR list
*
* Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz)
* Karel Slany (slany AT fit.vutbr.cz)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the organization nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
/* ========================================================================= */
/* SWIG setting and definitions. */
/* ========================================================================= */
/* Creates a temporary instance of (ldns_rr *). */
%typemap(in, numinputs=0, noblock=1) (ldns_rr **)
{
ldns_rr *$1_rr;
$1 = &$1_rr;
}
/* Result generation, appends (ldns_rr *) after the result. */
%typemap(argout, noblock=1) (ldns_rr **)
{
$result = SWIG_Python_AppendOutput($result,
SWIG_NewPointerObj(SWIG_as_voidptr($1_rr),
SWIGTYPE_p_ldns_struct_rr, SWIG_POINTER_OWN | 0 ));
}
%nodefaultctor ldns_struct_rr; /* No default constructor. */
%nodefaultdtor ldns_struct_rr; /* No default destructor. */
%ignore ldns_struct_rr::_rdata_fields;
%newobject ldns_rr_clone;
%newobject ldns_rr_new;
%newobject ldns_rr_new_frm_type;
%newobject ldns_rr_pop_rdf;
%delobject ldns_rr_free;
%rename(ldns_rr) ldns_struct_rr;
%newobject ldns_rr2str;
%newobject ldns_rr_type2str;
%newobject ldns_rr_class2str;
%newobject ldns_read_anchor_file;
/* Clone rdf data on pull. */
/* Clone will fail with NULL argument. */
%newobject _ldns_rr_rdf;
%rename(__ldns_rr_rdf) ldns_rr_rdf;
%inline
%{
ldns_rdf * _ldns_rr_rdf(ldns_rr *rr, size_t i)
{
ldns_rdf *rdf;
rdf = ldns_rr_rdf(rr, i);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_rrsig_algorithm;
%rename(__ldns_rr_rrsig_algorithm) ldns_rr_rrsig_algorithm;
%inline
%{
ldns_rdf * _ldns_rr_rrsig_algorithm(ldns_rr *rr) {
ldns_rdf *rdf;
rdf = ldns_rr_rrsig_algorithm(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_dnskey_algorithm;
%rename(__ldns_rr_dnskey_algorithm) ldns_rr_dnskey_algorithm;
%inline
%{
ldns_rdf * _ldns_rr_dnskey_algorithm(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_dnskey_algorithm(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_dnskey_flags;
%rename(__ldns_rr_dnskey_flags) ldns_rr_dnskey_flags;
%inline
%{
ldns_rdf * _ldns_rr_dnskey_flags(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_dnskey_flags(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_dnskey_key;
%rename(__ldns_rr_dnskey_key) ldns_rr_dnskey_key;
%inline
%{
ldns_rdf * _ldns_rr_dnskey_key(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_dnskey_key(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_dnskey_protocol;
%rename(__ldns_rr_dnskey_protocol) ldns_rr_dnskey_protocol;
%inline
%{
ldns_rdf * _ldns_rr_dnskey_protocol(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_dnskey_protocol(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_owner;
%rename(__ldns_rr_owner) ldns_rr_owner;
%inline
%{
ldns_rdf * _ldns_rr_owner(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_owner(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_a_address;
%rename(__ldns_rr_a_address) ldns_rr_a_address;
%inline
%{
ldns_rdf * _ldns_rr_a_address(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_a_address(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_mx_exchange;
%rename(__ldns_rr_mx_exchange) ldns_rr_mx_exchange;
%inline
%{
ldns_rdf * _ldns_rr_mx_exchange(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_mx_exchange(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_mx_preference;
%rename(__ldns_rr_mx_preference) ldns_rr_mx_preference;
%inline
%{
ldns_rdf * _ldns_rr_mx_preference(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_mx_preference(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_ns_nsdname;
%rename(__ldns_rr_ns_nsdname) ldns_rr_ns_nsdname;
%inline
%{
ldns_rdf * _ldns_rr_ns_nsdname(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_ns_nsdname(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_rrsig_expiration;
%rename(__ldns_rr_rrsig_expiration) ldns_rr_rrsig_expiration;
%inline
%{
ldns_rdf * _ldns_rr_rrsig_expiration(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_rrsig_expiration(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_rrsig_inception;
%rename(__ldns_rr_rrsig_inception) ldns_rr_rrsig_inception;
%inline
%{
ldns_rdf * _ldns_rr_rrsig_inception(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_rrsig_inception(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_rrsig_keytag;
%rename(__ldns_rr_rrsig_keytag) ldns_rr_rrsig_keytag;
%inline
%{
ldns_rdf * _ldns_rr_rrsig_keytag(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_rrsig_keytag(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_rrsig_labels;
%rename(__ldns_rr_rrsig_labels) ldns_rr_rrsig_labels;
%inline
%{
ldns_rdf * _ldns_rr_rrsig_labels(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_rrsig_labels(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_rrsig_origttl;
%rename(__ldns_rr_rrsig_origttl) ldns_rr_rrsig_origttl;
%inline
%{
ldns_rdf * _ldns_rr_rrsig_origttl(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_rrsig_origttl(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_rrsig_sig;
%rename(__ldns_rr_rrsig_sig) ldns_rr_rrsig_sig;
%inline
%{
ldns_rdf * _ldns_rr_rrsig_sig(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_rrsig_sig(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_rrsig_signame;
%rename(__ldns_rr_rrsig_signame) ldns_rr_rrsig_signame;
%inline
%{
ldns_rdf * _ldns_rr_rrsig_signame(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_rrsig_signame(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
%newobject _ldns_rr_rrsig_typecovered;
%rename(__ldns_rr_rrsig_typecovered) ldns_rr_rrsig_typecovered;
%inline
%{
ldns_rdf * _ldns_rr_rrsig_typecovered(ldns_rr *rr)
{
ldns_rdf *rdf;
rdf = ldns_rr_rrsig_typecovered(rr);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
/* End of pull cloning. */
/* Clone rdf data on push. */
%rename(__ldns_rr_a_set_address) ldns_rr_a_set_address;
%inline
%{
bool _ldns_rr_a_set_address(ldns_rr *rr, ldns_rdf *rdf)
{
return ldns_rr_a_set_address(rr, ldns_rdf_clone(rdf));
}
%}
%rename(__ldns_rr_dnskey_set_algorithm) ldns_rr_dnskey_set_algorithm;
%inline
%{
bool _ldns_rr_dnskey_set_algorithm(ldns_rr *rr, ldns_rdf *rdf)
{
return ldns_rr_dnskey_set_algorithm(rr, ldns_rdf_clone(rdf));
}
%}
%rename(__ldns_rr_dnskey_set_flags) ldns_rr_dnskey_set_flags;
%inline
%{
bool _ldns_rr_dnskey_set_flags(ldns_rr *rr, ldns_rdf *rdf)
{
return ldns_rr_dnskey_set_flags(rr, ldns_rdf_clone(rdf));
}
%}
%rename(__ldns_rr_dnskey_set_key) ldns_rr_dnskey_set_key;
%inline
%{
bool _ldns_rr_dnskey_set_key(ldns_rr *rr, ldns_rdf *rdf)
{
return ldns_rr_dnskey_set_key(rr, ldns_rdf_clone(rdf));
}
%}
%rename(__ldns_rr_dnskey_set_protocol) ldns_rr_dnskey_set_protocol;
%inline
%{
bool _ldns_rr_dnskey_set_protocol(ldns_rr *rr, ldns_rdf *rdf)
{
return ldns_rr_dnskey_set_protocol(rr, ldns_rdf_clone(rdf));
}
%}
%rename(__ldns_rr_push_rdf) ldns_rr_push_rdf;
%inline
%{
bool _ldns_rr_push_rdf(ldns_rr *rr, ldns_rdf *rdf)
{
return ldns_rr_push_rdf(rr, ldns_rdf_clone(rdf));
}
%}
%rename(__ldns_rr_rrsig_set_algorithm) ldns_rr_rrsig_set_algorithm;
%inline
%{
bool _ldns_rr_rrsig_set_algorithm(ldns_rr *rr, ldns_rdf *rdf)
{
return ldns_rr_rrsig_set_algorithm(rr, ldns_rdf_clone(rdf));
}
%}
%rename(__ldns_rr_rrsig_set_expiration) ldns_rr_rrsig_set_expiration;
%inline
%{
bool _ldns_rr_rrsig_set_expiration(ldns_rr *rr, ldns_rdf *rdf)
{
return ldns_rr_rrsig_set_expiration(rr, ldns_rdf_clone(rdf));
}
%}
%rename(__ldns_rr_rrsig_set_inception) ldns_rr_rrsig_set_inception;
%inline
%{
bool _ldns_rr_rrsig_set_inception(ldns_rr *rr, ldns_rdf *rdf)
{
return ldns_rr_rrsig_set_inception(rr, ldns_rdf_clone(rdf));
}
%}
%rename(__ldns_rr_rrsig_set_keytag) ldns_rr_rrsig_set_keytag;
%inline
%{
bool _ldns_rr_rrsig_set_keytag(ldns_rr *rr, ldns_rdf *rdf)
{
return ldns_rr_rrsig_set_keytag(rr, ldns_rdf_clone(rdf));
}
%}
%rename(__ldns_rr_rrsig_set_labels) ldns_rr_rrsig_set_labels;
%inline
%{
bool _ldns_rr_rrsig_set_labels(ldns_rr *rr, ldns_rdf *rdf)
{
return ldns_rr_rrsig_set_labels(rr, ldns_rdf_clone(rdf));
}
%}
%rename(__ldns_rr_rrsig_set_origttl) ldns_rr_rrsig_set_origttl;
%inline
%{
bool _ldns_rr_rrsig_set_origttl(ldns_rr *rr, ldns_rdf *rdf)
{
return ldns_rr_rrsig_set_origttl(rr, ldns_rdf_clone(rdf));
}
%}
%rename(__ldns_rr_rrsig_set_sig) ldns_rr_rrsig_set_sig;
%inline
%{
bool _ldns_rr_rrsig_set_sig(ldns_rr *rr, ldns_rdf *rdf) {
return ldns_rr_rrsig_set_sig(rr, ldns_rdf_clone(rdf));
}
%}
%rename(__ldns_rr_rrsig_set_signame) ldns_rr_rrsig_set_signame;
%inline
%{
bool _ldns_rr_rrsig_set_signame(ldns_rr *rr, ldns_rdf *rdf)
{
return ldns_rr_rrsig_set_signame(rr, ldns_rdf_clone(rdf));
}
%}
%rename(__ldns_rr_rrsig_set_typecovered) ldns_rr_rrsig_set_typecovered;
%inline
%{
bool _ldns_rr_rrsig_set_typecovered(ldns_rr *rr, ldns_rdf *rdf)
{
return ldns_rr_rrsig_set_typecovered(rr, ldns_rdf_clone(rdf));
}
%}
%rename(__ldns_rr_set_owner) ldns_rr_set_owner;
%inline
%{
void _ldns_rr_set_owner(ldns_rr *rr, ldns_rdf *rdf)
{
return ldns_rr_set_owner(rr, ldns_rdf_clone(rdf));
}
%}
%newobject _ldns_rr_set_rdf;
%rename(__ldns_rr_set_rdf) ldns_rr_set_rdf;
%inline
%{
ldns_rdf * _ldns_rr_set_rdf(ldns_rr *rr, ldns_rdf *rdf, size_t pos)
{
/* May leak memory on unsuccessful calls. */
ldns_rdf *new, *ret;
new = ldns_rdf_clone(rdf);
if ((ret = ldns_rr_set_rdf(rr, new, pos)) == NULL) {
ldns_rdf_deep_free(new);
}
return ret;
}
%}
/* End of push cloning. */
%rename(_ldns_rr_new_frm_str) ldns_rr_new_frm_str;
%rename(_ldns_rr_new_frm_fp_l) ldns_rr_new_frm_fp_l;
%rename(_ldns_rr_new_frm_fp) ldns_rr_new_frm_fp;
/* ========================================================================= */
/* Debugging related code. */
/* ========================================================================= */
#ifdef LDNS_DEBUG
%rename(__ldns_rr_free) ldns_rr_free;
%inline %{
void _ldns_rr_free (ldns_rr *r)
{
printf("******** LDNS_RR free 0x%lX ************\n", (long unsigned int)r);
ldns_rr_free(r);
}
%}
#else /* !LDNS_DEBUG */
%rename(_ldns_rr_free) ldns_rr_free;
#endif /* LDNS_DEBUG */
/* ========================================================================= */
/* Added C code. */
/* ========================================================================= */
/* None. */
/* ========================================================================= */
/* Encapsulating Python code. */
/* ========================================================================= */
%feature("docstring") ldns_struct_rr "Resource Record (RR).
The RR is the basic DNS element that contains actual data. This class allows
to create RR and manipulate with the content.
Use :meth:`ldns_rr_new`, :meth:`ldns_rr_new_frm_type`, :meth:`new_frm_fp`,
:meth:`new_frm_fp_l`, :meth:`new_frm_str` or :meth:`new_question_frm_str`
to create :class:`ldns_rr` instances.
"
%extend ldns_struct_rr {
%pythoncode
%{
def __init__(self):
raise Exception("This class can't be created directly. " +
"Please use: ldns_rr_new(), ldns_rr_new_frm_type(), " +
"new_frm_fp(), new_frm_fp_l(), new_frm_str() or " +
"new_question_frm_str()")
__swig_destroy__ = _ldns._ldns_rr_free
#
# LDNS_RR_CONSTRUCTORS_
#
@staticmethod
def new_frm_str(string, default_ttl=0, origin=None, prev=None, raiseException=True):
"""
Creates an rr object from a string.
The string should be a fully filled-in rr, like "owner_name
[space] TTL [space] CLASS [space] TYPE [space] RDATA."
:param string: The string to convert.
:type string: str
:param default_ttl: Default ttl value for the rr.
If 0 DEF_TTL will be used.
:type default_ttl: int
:param origin: When the owner is relative add this.
:type origin: :class:`ldns_dname`
:param prev: The previous owner name.
:type prev: :class:`ldns_rdf`
:param raiseException: If True, an exception occurs in case a rr
instance can't be created.
:throws Exception: If `raiseExceprion` is set and fails.
:throws TypeError: When parameters of incorrect types.
:return: (:class:`ldns_rr`) RR instance or None.
.. note::
The type checking of `origin` is benevolent.
It allows also to pass a dname :class:`ldns_rdf` object.
This will probably change in future.
**Usage**
>>> import ldns
>>> rr = ldns.ldns_rr.new_frm_str("www.nic.cz. IN A 192.168.1.1", 300)
>>> print rr
www.nic.cz. 300 IN A 192.168.1.1
>>> rr = ldns.ldns_rr.new_frm_str("test.nic.cz. 600 IN A 192.168.1.2")
>>> print rr
test.nic.cz. 600 IN A 192.168.1.2
"""
if (not isinstance(origin, ldns_dname)) and \
isinstance(origin, ldns_rdf) and \
origin.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
warnings.warn("The ldns_rr.new_frm_str() method will" +
" drop the possibility to accept ldns_rdf as origin." +
" Convert argument to ldns_dname.",
PendingDeprecationWarning, stacklevel=2)
status, rr, prev = _ldns.ldns_rr_new_frm_str_(string, default_ttl,
origin, prev)
if status != LDNS_STATUS_OK:
if (raiseException):
raise Exception("Can't create RR, error: %d" % status)
return None
return rr
@staticmethod
def new_question_frm_str(string, default_ttl=0, origin=None, prev=None, raiseException=True):
"""
Creates an rr object from a string.
The string is like :meth:`new_frm_str` but without rdata.
:param string: The string to convert.
:type string: str
:param origin: When the owner is relative add this.
:type origin: :class:`ldns_dname`
:param prev: The previous owner name.
:type prev: :class:`ldns_rdf`
:param raiseException: If True, an exception occurs in case
a rr instance can't be created.
:throws Exception: If `raiseExceprion` is set and fails.
:throws TypeError: When parameters of incorrect types.
:return: (:class:`ldns_rr`) RR instance or None. If the object
can't be created and `raiseException` is True,
an exception occurs.
.. note::
The type checking of `origin` is benevolent.
It allows also to pass a dname :class:`ldns_rdf` object.
This will probably change in future.
"""
if (not isinstance(origin, ldns_dname)) and \
isinstance(origin, ldns_rdf) and \
origin.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
warnings.warn("The ldns_rr.new_question_frm_str() method will" +
" drop the possibility to accept ldns_rdf as origin." +
" Convert argument to ldns_dname.",
PendingDeprecationWarning, stacklevel=2)
status, rr, prev = _ldns.ldns_rr_new_question_frm_str_(string,
origin, prev)
if status != LDNS_STATUS_OK:
if (raiseException):
raise Exception("Can't create RR, error: %d" % status)
return None
return rr
@staticmethod
def new_frm_str_prev(string, default_ttl=0, origin=None, prev=None, raiseException=True):
"""
Creates an rr object from a string.
The string should be a fully filled-in rr, like "owner_name
[space] TTL [space] CLASS [space] TYPE [space] RDATA".
:param string: The string to convert.
:type string: str
:param default_ttl: Default ttl value for the rr.
If 0 DEF_TTL will be used.
:type default_ttl: int
:param origin: When the owner is relative add this.
:type origin: :class:`ldns_dname`
:param prev: The previous owner name.
:type prev: :class:`ldns_rdf`
:param raiseException: If True, an exception occurs in case when
a rr instance can't be created.
:throws Exception: If `raiseExceprion` is set and fails.
:throws TypeError: When parameters of incorrect types.
:return: None when fails, otherwise a tuple containing:
* rr - (:class:`ldns_rr`) RR instance or None.
If the object can't be created and `raiseException`
is True, an exception occurs.
* prev - (:class:`ldns_rdf`) Owner name found in this string
or None.
.. note::
The type checking of `origin` is benevolent.
It allows also to pass a dname :class:`ldns_rdf` object.
This will probably change in future.
"""
if (not isinstance(origin, ldns_dname)) and \
isinstance(origin, ldns_rdf) and \
origin.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
warnings.warn("The ldns_rr.new_frm_str_prev() method will" +
" drop the possibility to accept ldns_rdf as origin." +
" Convert argument to ldns_dname.",
PendingDeprecationWarning, stacklevel=2)
status, rr, prev = _ldns.ldns_rr_new_frm_str_(string, default_ttl,
origin, prev)
if status != LDNS_STATUS_OK:
if (raiseException):
raise Exception("Can't create RR, error: %d" % status)
return None
return rr, prev
@staticmethod
def new_frm_fp(file, default_ttl=0, origin=None, prev=None, raiseException=True):
"""
Creates a new rr from a file containing a string.
:param file: Opened file.
:param default_ttl: If 0 DEF_TTL will be used.
:type default_ttl: int
:param origin: When the owner is relative add this.
:type origin: :class:`ldns_dname`
:param prev: When the owner is white spaces use this.
:type prev: :class:`ldns_rdf`
:param raiseException: If True, an exception occurs in case
a resolver object can't be created.
:throws Exception: If `raiseException` is set and the input
cannot be read.
:throws TypeError: When parameters of incorrect types.
:return: None when fails, otherwise a tuple containing:
* rr - (:class:`ldns_rr`) RR object or None. If the object
can't be created and `raiseException` is True,
an exception occurs.
* ttl - (int) None or TTL if the file contains a TTL
directive.
* origin - (:class:`ldns_rdf`) None or dname rdf if the file
contains a ORIGIN directive.
* prev - (:class:`ldns_rdf`) None or updated value
of prev parameter.
.. note::
The type checking of `origin` is benevolent.
It allows also to pass a dname :class:`ldns_rdf` object.
This will probably change in future.
"""
if (not isinstance(origin, ldns_dname)) and \
isinstance(origin, ldns_rdf) and \
origin.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
warnings.warn("The ldns_rr.new_frm_fp() method will" +
" drop the possibility to accept ldns_rdf as origin." +
" Convert argument to ldns_dname.",
PendingDeprecationWarning, stacklevel=2)
res = _ldns.ldns_rr_new_frm_fp_(file, default_ttl, origin, prev)
if res[0] != LDNS_STATUS_OK:
if (raiseException):
raise Exception("Can't create RR, error: %d" % res[0])
return None
return res[1:]
@staticmethod
def new_frm_fp_l(file, default_ttl=0, origin=None, prev=None, raiseException=True):
"""
Creates a new rr from a file containing a string.
:param file: Opened file.
:param default_ttl: If 0 DEF_TTL will be used.
:type default_ttl: int
:param origin: When the owner is relative add this.
:type origin: :class:`ldns_dname`
:param prev: When the owner is white spaces use this.
:type prev: :class:`ldns_rdf`
:param raiseException: Iif True, an exception occurs in case
a resolver object can't be created.
:throws Exception: If `raiseException` is set and the input
cannot be read.
:throws TypeError: When parameters of incorrect types.
:return: None when fails, otherwise a tuple containing:
* rr - (:class:`ldns_rr`) RR object or None. If the object
can't be created and `raiseException` is True,
an exception occurs.
* line - (int) line number (for debugging).
* ttl - (int) None or TTL if the file contains a TTL
directive .
* origin - (:class:`ldns_rdf`) None or dname rdf if the file
contains a ORIGIN directive.
* prev - (:class:`ldns_rdf`) None or updated value of prev
parameter.
.. note::
The type checking of `origin` is benevolent.
It allows also to pass a dname :class:`ldns_rdf` object.
This will probably change in future.
"""
if (not isinstance(origin, ldns_dname)) and \
isinstance(origin, ldns_rdf) and \
origin.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
warnings.warn("The ldns_rr.new_frm_fp_l() method will" +
" drop the possibility to accept ldns_rdf as origin." +
" Convert argument to ldns_dname.",
PendingDeprecationWarning, stacklevel=2)
res = _ldns.ldns_rr_new_frm_fp_l_(file, default_ttl, origin, prev)
if res[0] != LDNS_STATUS_OK:
if (raiseException):
raise Exception("Can't create RR, error: %d" % res[0])
return None
return res[1:]
#
# _LDNS_RR_CONSTRUCTORS
#
def __str__(self):
"""
Converts the data in the resource record to presentation format.
:return: (str)
"""
return _ldns.ldns_rr2str(self)
def __cmp__(self, other):
"""
Compares two rrs.
The TTL is not looked at.
:param other: The second RR one.
:type other: :class:`ldns_rr`
:throws TypeError: When `other` of non-:class:`ldns_rr` type.
:return: (int) 0 if equal, -1 if `self` comes before `other`,
1 if `other` RR comes before `self`.
"""
return _ldns.ldns_rr_compare(self, other)
def __lt__(self, other):
"""
Compares two rrs.
The TTL is not looked at.
:param other: The second RR one.
:type other: :class:`ldns_rr`
:throws TypeError: When `other` of non-:class:`ldns_rr` type.
:return: (bool) True when `self` is less than 'other'.
"""
return _ldns.ldns_rr_compare(self, other) == -1
def __le__(self, other):
"""
Compares two rrs.
The TTL is not looked at.
:param other: The second RR one.
:type other: :class:`ldns_rr`
:throws TypeError: When `other` of non-:class:`ldns_rr` type.
:return: (bool) True when `self` is less than or equal to
'other'.
"""
return _ldns.ldns_rr_compare(self, other) != 1
def __eq__(self, other):
"""
Compares two rrs.
The TTL is not looked at.
:param other: The second RR one.
:type other: :class:`ldns_rr`
:throws TypeError: When `other` of non-:class:`ldns_rr` type.
:return: (bool) True when `self` is equal to 'other'.
"""
return _ldns.ldns_rr_compare(self, other) == 0
def __ne__(self, other):
"""
Compares two rrs.
The TTL is not looked at.
:param other: The second RR one.
:type other: :class:`ldns_rr`
:throws TypeError: When `other` of non-:class:`ldns_rr` type.
:return: (bool) True when `self` is not equal to 'other'.
"""
return _ldns.ldns_rr_compare(self, other) != 0
def __gt__(self, other):
"""
Compares two rrs.
The TTL is not looked at.
:param other: The second RR one.
:type other: :class:`ldns_rr`
:throws TypeError: When `other` of non-:class:`ldns_rr` type.
:return: (bool) True when `self` is greater than 'other'.
"""
return _ldns.ldns_rr_compare(self, other) == 1
def __ge__(self, other):
"""
Compares two rrs.
The TTL is not looked at.
:param other: The second RR one.
:type other: :class:`ldns_rr`
:throws TypeError: When `other` of non-:class:`ldns_rr` type.
:return: (bool) True when `self` is greater than or equal to
'other'.
"""
return _ldns.ldns_rr_compare(self, other) != -1
@staticmethod
def class_by_name(string):
"""
Retrieves a class identifier value by looking up its name.
:param string: Class name.
:type string: str
:throws TypeError: when `string` of inappropriate type.
:return: (int) Class identifier value, or 0 if not valid
class name given.
"""
return _ldns.ldns_get_rr_class_by_name(string)
def rdfs(self):
"""
Returns a generator object of rdata records.
:return: Generator of :class:`ldns_rdf`.
"""
for i in range(0, self.rd_count()):
yield self.rdf(i)
def print_to_file(self, output):
"""
Prints the data in the resource record to the given file stream
(in presentation format).
:param output: Opened file stream.
:throws TypeError: When `output` not a file.
"""
_ldns.ldns_rr_print(output, self)
#parameters: FILE *, const ldns_rr *,
def get_type_str(self):
"""
Converts an RR type value to its string representation,
and returns that string.
:return: (str) containing type identification.
"""
return _ldns.ldns_rr_type2str(self.get_type())
#parameters: const ldns_rr_type,
def get_class_str(self):
"""
Converts an RR class value to its string representation,
and returns that string.
:return: (str) containing class identification.
"""
return _ldns.ldns_rr_class2str(self.get_class())
#parameters: const ldns_rr_class,
@staticmethod
def dnskey_key_size_raw(keydata, len, alg):
"""
Get the length of the keydata in bits.
:param keydata: Key raw data.
:type keydata: unsigned char \*
:param len: Number of bytes of `keydata`.
:type len: size_t
:param alg: Algorithm identifier.
:type alg: ldns_algorithm
:return: (size_t) The length of key data in bits.
"""
return _ldns.ldns_rr_dnskey_key_size_raw(keydata, len, alg)
#parameters: const unsigned char *,const size_t,const ldns_algorithm,
#retvals: size_t
def write_to_buffer(self,buffer,section):
"""
Copies the rr data to the buffer in wire format.
:param buffer: Buffer to append the result to.
:type buffer: :class:`ldns_buffer`
:param section: The section in the packet this rr is supposed
to be in (to determine whether to add rdata or not).
:type section: int
:throws TypeError: when arguments of mismatching types passed.
:return: (ldns_status) ldns_status
"""
return _ldns.ldns_rr2buffer_wire(buffer, self, section)
#parameters: ldns_buffer *,const ldns_rr *,int,
#retvals: ldns_status
def write_to_buffer_canonical(self,buffer,section):
"""
Copies the rr data to the buffer in wire format, in canonical
format according to RFC3597 (every dname in rdata fields
of RR's mentioned in that RFC will be converted to lower-case).
:param buffer: Buffer to append the result to.
:type buffer: :class:`ldns_buffer`
:param section: The section in the packet this rr is supposed
to be in (to determine whether to add rdata or not).
:type section: int
:throws TypeError: when arguments of mismatching types passed.
:return: (ldns_status) ldns_status
"""
return _ldns.ldns_rr2buffer_wire_canonical(buffer,self,section)
#parameters: ldns_buffer *,const ldns_rr *,int,
#retvals: ldns_status
def write_data_to_buffer(self, buffer):
"""
Converts an rr's rdata to wire format, while excluding the
owner name and all the stuff before the rdata.
This is needed in DNSSEC key-tag calculation, the ds
calculation from the key and maybe elsewhere.
:param buffer: Buffer to append the result to.
:type buffer: :class:`ldns_buffer`
:throws TypeError: when `buffer` of non-:class:`ldns_buffer`
type.
:return: (ldns_status) ldns_status
"""
return _ldns.ldns_rr_rdata2buffer_wire(buffer,self)
#parameters: ldns_buffer *, const ldns_rr *,
#retvals: ldns_status
def write_rrsig_to_buffer(self, buffer):
"""
Converts a rrsig to wire format BUT EXCLUDE the rrsig rdata.
This is needed in DNSSEC verification.
:param buffer: Buffer to append the result to.
:type buffer: :class:`ldns_buffer`
:throws TypeError: when `buffer` of non-:class:`ldns_buffer`
type.
:return: (ldns_status) ldns_status
"""
return _ldns.ldns_rrsig2buffer_wire(buffer,self)
#parameters: ldns_buffer *,const ldns_rr *,
#retvals: ldns_status
#
# LDNS_RR_METHODS_
#
def a_address(self):
"""
Returns the address rdf of a LDNS_RR_TYPE_A or LDNS_RR_TYPE_AAAA
rr.
:return: (:class:`ldns_rdf`) with the address or None on
failure.
"""
return _ldns._ldns_rr_a_address(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def a_set_address(self, f):
"""
Sets the address of a LDNS_RR_TYPE_A or LDNS_RR_TYPE_AAAA rr.
:param f: The address to be set.
:type f: :class:`ldns_rdf`
:throws TypeError: When `f` of non-:class:`ldns_rdf` type.
:return: (bool) True on success, False otherwise.
"""
return _ldns._ldns_rr_a_set_address(self, f)
#parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
def clone(self):
"""
Clones a rr and all its data.
:return: (:class:`ldns_rr`) The new rr or None on failure.
"""
return _ldns.ldns_rr_clone(self)
#parameters: const ldns_rr *,
#retvals: ldns_rr *
def compare_ds(self, rr2):
"""
Returns True if the given rr's are equal.
Also returns True if one record is a DS that represents the
same DNSKEY record as the other record.
:param rr2: The second rr.
:type rr2: :class:`ldns_rr`
:throws TypeError: When `rr2` of non-:class:`ldns_rr` type.
:return: (bool) True if equal otherwise False.
"""
return _ldns.ldns_rr_compare_ds(self, rr2)
#parameters: const ldns_rr *, const ldns_rr *,
#retvals: bool
def compare_no_rdata(self, rr2):
"""
Compares two rrs, up to the rdata.
:param rr2: Rhe second rr.
:type rr2: :class:`ldns_rr`
:throws TypeError: When `rr2` of non-:class:`ldns_rr` type.
:return: (int) 0 if equal, negative integer if `self` comes
before `rr2`, positive integer if `rr2` comes before `self`.
"""
return _ldns.ldns_rr_compare_no_rdata(self, rr2)
#parameters: const ldns_rr *, const ldns_rr *,
#retvals: int
def dnskey_algorithm(self):
"""
Returns the algorithm of a LDNS_RR_TYPE_DNSKEY rr.
:return: (:class:`ldns_rdf`) with the algorithm or None
on failure.
"""
return _ldns._ldns_rr_dnskey_algorithm(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def dnskey_flags(self):
"""
Returns the flags of a LDNS_RR_TYPE_DNSKEY rr.
:return: (:class:`ldns_rdf`) with the flags or None on failure.
"""
return _ldns._ldns_rr_dnskey_flags(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def dnskey_key(self):
"""
Returns the key data of a LDNS_RR_TYPE_DNSKEY rr.
:return: (:class:`ldns_rdf`) with the key data or None on
failure.
"""
return _ldns._ldns_rr_dnskey_key(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def dnskey_key_size(self):
"""
Get the length of the keydata in bits.
:return: (size_t) the keysize in bits.
"""
return _ldns.ldns_rr_dnskey_key_size(self)
#parameters: const ldns_rr *,
#retvals: size_t
def dnskey_protocol(self):
"""
Returns the protocol of a LDNS_RR_TYPE_DNSKEY rr.
:return: (:class:`ldns_rdf`) with the protocol or None on
failure.
"""
return _ldns._ldns_rr_dnskey_protocol(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def dnskey_set_algorithm(self, f):
"""
Sets the algorithm of a LDNS_RR_TYPE_DNSKEY rr
:param f: The algorithm to set.
:type f: :class:`ldns_rdf`
:throws TypeError: When `f` of non-:class:`ldns_rdf` type.
:return: (bool) True on success, False otherwise.
"""
return _ldns._ldns_rr_dnskey_set_algorithm(self, f)
#parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
def dnskey_set_flags(self, f):
"""
Sets the flags of a LDNS_RR_TYPE_DNSKEY rr.
:param f: The flags to be set.
:type f: :class:`ldns_rdf`
:throws TypeError: When `f` of non-:class:`ldns_rdf` type.
:return: (bool) True on success, False otherwise.
"""
return _ldns._ldns_rr_dnskey_set_flags(self, f)
#parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
def dnskey_set_key(self, f):
"""
Sets the key data of a LDNS_RR_TYPE_DNSKEY rr.
:param f: The key data to set.
:type f: :class:`ldns_rdf`
:throws TypeError: When `f` of non-:class:`ldns_rdf` type.
:return: (bool) True on success, False otherwise.
"""
return _ldns._ldns_rr_dnskey_set_key(self, f)
#parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
def dnskey_set_protocol(self,f):
"""
Sets the protocol of a LDNS_RR_TYPE_DNSKEY rr.
:param f: The protocol to set.
:type f: :class:`ldns_rdf`
:throws TypeError: When `f` of non-:class:`ldns_rdf` type.
:return: (bool) True on success, False otherwise.
"""
return _ldns._ldns_rr_dnskey_set_protocol(self,f)
#parameters: ldns_rr *,ldns_rdf *,
#retvals: bool
def get_class(self):
"""
Returns the class of the rr.
:return: (int) The class identifier of the rr.
"""
return _ldns.ldns_rr_get_class(self)
#parameters: const ldns_rr *,
#retvals: ldns_rr_class
def get_type(self):
"""
Returns the type of the rr.
:return: (int) The type identifier of the rr.
"""
return _ldns.ldns_rr_get_type(self)
#parameters: const ldns_rr *,
#retvals: ldns_rr_type
def is_question(self):
"""
Returns the question flag of a rr structure.
:return: (bool) True if question flag is set.
"""
return _ldns.ldns_rr_is_question(self)
def label_count(self):
"""
Counts the number of labels of the owner name.
:return: (int) The number of labels.
"""
return _ldns.ldns_rr_label_count(self)
#parameters: ldns_rr *,
#retvals: uint8_t
def mx_exchange(self):
"""
Returns the mx host of a LDNS_RR_TYPE_MX rr.
:return: (:class:`ldns_rdf`) with the name of the MX host
or None on failure.
"""
return _ldns._ldns_rr_mx_exchange(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def mx_preference(self):
"""
Returns the mx preference of a LDNS_RR_TYPE_MX rr.
:return: (:class:`ldns_rdf`) with the preference or None
on failure.
"""
return _ldns._ldns_rr_mx_preference(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def ns_nsdname(self):
"""
Returns the name of a LDNS_RR_TYPE_NS rr.
:return: (:class:`ldns_rdf`) A dname rdf with the name or
None on failure.
"""
return _ldns._ldns_rr_ns_nsdname(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def owner(self):
"""
Returns the owner name of an rr structure.
:return: (:class:`ldns_dname`) Owner name or None on failure.
"""
rdf = _ldns._ldns_rr_owner(self)
if rdf:
rdf = ldns_dname(rdf, clone=False)
return rdf
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def pop_rdf(self):
"""
Removes a rd_field member, it will be popped from the last
position.
:return: (:class:`ldns_rdf`) rdf which was popped, None if
nothing.
"""
return _ldns.ldns_rr_pop_rdf(self)
#parameters: ldns_rr *,
#retvals: ldns_rdf *
def push_rdf(self,f):
"""
Sets rd_field member, it will be placed in the next available
spot.
:param f: The rdf to be appended.
:type f: :class:`ldns_rdf`
:throws TypeError: When `f` of non-:class:`ldns_rdf` type.
:return: (bool) Returns True if success, False otherwise.
"""
return _ldns._ldns_rr_push_rdf(self, f)
#parameters: ldns_rr *, const ldns_rdf *,
#retvals: bool
def rd_count(self):
"""
Returns the rd_count of an rr structure.
:return: (size_t) the rd count of the rr.
"""
return _ldns.ldns_rr_rd_count(self)
#parameters: const ldns_rr *,
#retvals: size_t
def rdf(self, nr):
"""
Returns the rdata field with the given index.
:param nr: The index of the rdf to return.
:type nr: positive int
:throws TypeError: When `nr` not a positive integer.
:return: (:class:`ldns_rdf`) The given rdf or None if fails.
"""
return _ldns._ldns_rr_rdf(self, nr)
#parameters: const ldns_rr *, size_t,
#retvals: ldns_rdf *
def rrsig_algorithm(self):
"""
Returns the algorithm identifier of a LDNS_RR_TYPE_RRSIG RR.
:return: (:class:`ldns_rdf`) with the algorithm or None
on failure.
"""
return _ldns._ldns_rr_rrsig_algorithm(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def rrsig_expiration(self):
"""
Returns the expiration time of a LDNS_RR_TYPE_RRSIG RR.
:return: (:class:`ldns_rdf`) with the expiration time or None
on failure.
"""
return _ldns._ldns_rr_rrsig_expiration(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def rrsig_inception(self):
"""
Returns the inception time of a LDNS_RR_TYPE_RRSIG RR.
:return: (:class:`ldns_rdf`) with the inception time or None
on failure.
"""
return _ldns._ldns_rr_rrsig_inception(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def rrsig_keytag(self):
"""
Returns the keytag of a LDNS_RR_TYPE_RRSIG RR.
:return: (:class:`ldns_rdf`) with the keytag or None on failure.
"""
return _ldns._ldns_rr_rrsig_keytag(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def rrsig_labels(self):
"""
Returns the number of labels of a LDNS_RR_TYPE_RRSIG RR.
:return: (:class:`ldns_rdf`) with the number of labels or None
on failure.
"""
return _ldns._ldns_rr_rrsig_labels(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def rrsig_origttl(self):
"""
Returns the original TTL of a LDNS_RR_TYPE_RRSIG RR.
:return: (:class:`ldns_rdf`) with the original TTL or None
on failure.
"""
return _ldns._ldns_rr_rrsig_origttl(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def rrsig_set_algorithm(self, f):
"""
Sets the algorithm of a LDNS_RR_TYPE_RRSIG rr.
:param f: The algorithm to set.
:type f: :class:`ldns_rdf`
:throws TypeError: when `f` of non-:class:`ldns_rdf` type.
:return: (bool) True on success, False otherwise.
"""
return _ldns._ldns_rr_rrsig_set_algorithm(self, f)
#parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
def rrsig_set_expiration(self, f):
"""
Sets the expireation date of a LDNS_RR_TYPE_RRSIG rr.
:param f: The expireation date to set.
:type f: :class:`ldns_rdf`
:throws TypeError: when `f` of non-:class:`ldns_rdf` type.
:return: (bool) True on success, False otherwise.
"""
return _ldns._ldns_rr_rrsig_set_expiration(self, f)
#parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
def rrsig_set_inception(self, f):
"""
Sets the inception date of a LDNS_RR_TYPE_RRSIG rr.
:param f: The inception date to set.
:type f: :class:`ldns_rdf`
:throws TypeError: when `f` of non-:class:`ldns_rdf` type.
:return: (bool) True on success, False otherwise.
"""
return _ldns._ldns_rr_rrsig_set_inception(self, f)
#parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
def rrsig_set_keytag(self, f):
"""
Sets the keytag of a LDNS_RR_TYPE_RRSIG rr.
:param f: The keytag to set.
:type f: :class:`ldns_rdf`
:throws TypeError: when `f` of non-:class:`ldns_rdf` type.
:return: (bool) True on success, False otherwise.
"""
return _ldns._ldns_rr_rrsig_set_keytag(self, f)
#parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
def rrsig_set_labels(self, f):
"""
Sets the number of labels of a LDNS_RR_TYPE_RRSIG rr.
:param f: The number of labels to set.
:type f: :class:`ldns_rdf`
:throws TypeError: when `f` of non-:class:`ldns_rdf` type.
:return: (bool) True on success, False otherwise.
"""
return _ldns._ldns_rr_rrsig_set_labels(self, f)
#parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
def rrsig_set_origttl(self, f):
"""
Sets the original TTL of a LDNS_RR_TYPE_RRSIG rr.
:param f: The original TTL to set.
:type f: :class:`ldns_rdf`
:throws TypeError: when `f` of non-:class:`ldns_rdf` type.
:return: (bool) True on success, False otherwise.
"""
return _ldns._ldns_rr_rrsig_set_origttl(self, f)
#parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
def rrsig_set_sig(self, f):
"""
Sets the signature data of a LDNS_RR_TYPE_RRSIG rr.
:param f: The signature data to set.
:type f: :class:`ldns_rdf`
:throws TypeError: when `f` of non-:class:`ldns_rdf` type.
:return: (bool) True on success, False otherwise.
"""
return _ldns._ldns_rr_rrsig_set_sig(self, f)
#parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
def rrsig_set_signame(self, f):
"""
Sets the signers name of a LDNS_RR_TYPE_RRSIG rr.
:param f: The signers name to set.
:type f: :class:`ldns_rdf`
:throws TypeError: when `f` of non-:class:`ldns_rdf` type.
:return: (bool) True on success, False otherwise.
"""
return _ldns._ldns_rr_rrsig_set_signame(self, f)
#parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
def rrsig_set_typecovered(self, f):
"""
Sets the typecovered of a LDNS_RR_TYPE_RRSIG rr.
:param f: The type covered to set.
:type f: :class:`ldns_rdf`
:throws TypeError: when `f` of non-:class:`ldns_rdf` type.
:return: (bool) True on success, False otherwise.
"""
return _ldns._ldns_rr_rrsig_set_typecovered(self, f)
#parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
def rrsig_sig(self):
"""
Returns the signature data of a LDNS_RR_TYPE_RRSIG RR.
:return: (:class:`ldns_rdf`) with the signature data or None
on failure.
"""
return _ldns._ldns_rr_rrsig_sig(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def rrsig_signame(self):
"""
Returns the signers name of a LDNS_RR_TYPE_RRSIG RR.
:return: (:class:`ldns_rdf`) with the signers name or None
on failure.
"""
return _ldns._ldns_rr_rrsig_signame(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def rrsig_typecovered(self):
"""
Returns the type covered of a LDNS_RR_TYPE_RRSIG rr.
:return: (:class:`ldns_rdf`) with the type covered or None
on failure.
"""
return _ldns._ldns_rr_rrsig_typecovered(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def set_class(self, rr_class):
"""
Sets the class in the rr.
:param rr_class: Set to this class.
:type rr_class: int
:throws TypeError: when `rr_class` of non-integer type.
"""
_ldns.ldns_rr_set_class(self, rr_class)
#parameters: ldns_rr *, ldns_rr_class,
#retvals:
def set_owner(self, owner):
"""
Sets the owner in the rr structure.
:param owner: Owner name.
:type owner: :class:`ldns_dname`
:throws TypeError: when `owner` of non-:class:`ldns_dname` type.
.. note::
The type checking of `owner` is benevolent.
It allows also to pass a dname :class:`ldns_rdf` object.
This will probably change in future.
"""
if (not isinstance(owner, ldns_dname)) and \
isinstance(owner, ldns_rdf) and \
owner.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
warnings.warn("The ldns_rr.new_frm_str() method will" +
" drop the possibility to accept ldns_rdf as owner." +
" Convert argument to ldns_dname.",
PendingDeprecationWarning, stacklevel=2)
_ldns._ldns_rr_set_owner(self, owner)
#parameters: ldns_rr *, ldns_rdf *,
#retvals:
def set_question(self, question):
"""
Sets the question flag in the rr structure.
:param question: Question flag.
:type question: bool
"""
_ldns.ldns_rr_set_question(self, question)
#parameters: ldns_rr *, bool,
#retvals:
def set_rd_count(self, count):
"""
Sets the rd_count in the rr.
:param count: Set to this count.
:type count: positive int
:throws TypeError: when `count` of non-integer type.
"""
_ldns.ldns_rr_set_rd_count(self, count)
#parameters: ldns_rr *, size_t,
#retvals:
def set_rdf(self, f, position):
"""
Sets a rdf member, it will be set on the position given.
The old value is returned, like pop.
:param f: The rdf to be set.
:type f: :class:`ldns_rdf`
:param position: The position the set the rdf.
:type position: positive int
:throws TypeError: when mismatching types passed.
:return: (:class:`ldns_rdf`) the old value in the rr, None
on failure.
"""
return _ldns._ldns_rr_set_rdf(self, f, position)
#parameters: ldns_rr *, const ldns_rdf *, size_t,
#retvals: ldns_rdf *
def set_ttl(self, ttl):
"""
Sets the ttl in the rr structure.
:param ttl: Set to this ttl.
:type ttl: positive int
:throws TypeError: when `ttl` of non-integer type.
"""
_ldns.ldns_rr_set_ttl(self, ttl)
#parameters: ldns_rr *, uint32_t,
#retvals:
def set_type(self, rr_type):
"""
Sets the type in the rr.
:param rr_type: Set to this type.
:type rr_type: ineteger
:throws TypeError: when `rr_type` of non-integer type.
"""
_ldns.ldns_rr_set_type(self, rr_type)
#parameters: ldns_rr *, ldns_rr_type,
#retvals:
def to_canonical(self):
"""
Converts each dname in a rr to its canonical form.
"""
_ldns.ldns_rr2canonical(self)
def ttl(self):
"""
Returns the ttl of an rr structure.
:return: (int) the ttl of the rr.
"""
return _ldns.ldns_rr_ttl(self)
#parameters: const ldns_rr *,
#retvals: uint32_t
@staticmethod
def type_by_name(string):
"""
Retrieves a rr type identifier value by looking up its name.
Returns 0 if invalid name passed.
:param string: RR type name.
:type string: str
:throws TypeError: when `string` of inappropriate type.
:return: (int) RR type identifier, or 0 if no matching value
to identifier found.
"""
return _ldns.ldns_get_rr_type_by_name(string)
def uncompressed_size(self):
"""
Calculates the uncompressed size of an RR.
:return: (inetger) size of the rr.
"""
return _ldns.ldns_rr_uncompressed_size(self)
#parameters: const ldns_rr *,
#retvals: size_t
#
# _LDNS_RR_METHODS
#
%}
}
/* ========================================================================= */
/* SWIG setting and definitions. */
/* ========================================================================= */
%nodefaultctor ldns_struct_rr_list; /* No default constructor. */
%nodefaultdtor ldns_struct_rr_list; /* No default destructor. */
%ignore ldns_struct_rr_list::_rrs;
%newobject ldns_rr_list_cat_clone;
%newobject ldns_rr_list_clone;
%newobject ldns_rr_list_pop_rr;
%newobject ldns_rr_list_pop_rr_list;
%newobject ldns_rr_list_pop_rrset;
%newobject ldns_rr_list_rr;
%newobject ldns_rr_list_new;
%newobject ldns_get_rr_list_hosts_frm_file;
%newobject ldns_rr_list_subtype_by_rdf;
%newobject ldns_rr_list2str;
%delobject ldns_rr_list_deep_free;
%delobject ldns_rr_list_free;
/* Clone data on push. */
%rename(__ldns_rr_list_push_rr) ldns_rr_list_push_rr;
%inline
%{
bool _ldns_rr_list_push_rr(ldns_rr_list* r, ldns_rr *rr)
{
bool ret;
ldns_rr *new;
new = ldns_rr_clone(rr);
if (!(ret = ldns_rr_list_push_rr(r, new))) {
ldns_rr_free(new);
}
return ret;
}
%}
%rename(__ldns_rr_list_push_rr_list) ldns_rr_list_push_rr_list;
%inline
%{
bool _ldns_rr_list_push_rr_list(ldns_rr_list* r, ldns_rr_list *r2)
{
bool ret;
ldns_rr_list *new;
new = ldns_rr_list_clone(r2);
if (!(ret = ldns_rr_list_push_rr_list(r, new))) {
ldns_rr_list_deep_free(new);
}
return ret;
}
%}
%newobject _ldns_rr_list_set_rr;
%rename(__ldns_rr_list_set_rr) ldns_rr_list_set_rr;
%inline
%{
ldns_rr * _ldns_rr_list_set_rr(ldns_rr_list * rrl, ldns_rr *rr,
size_t idx)
{
ldns_rr *ret;
ldns_rr *new;
new = ldns_rr_clone(rr);
if ((ret = ldns_rr_list_set_rr(rrl, new, idx)) == NULL) {
ldns_rr_free(new);
}
return ret;
}
%}
%rename(__ldns_rr_list_cat) ldns_rr_list_cat;
%inline
%{
bool _ldns_rr_list_cat(ldns_rr_list *r, ldns_rr_list *r2)
{
return ldns_rr_list_cat(r, ldns_rr_list_clone(r2));
}
%}
/* End clone data on push. */
/* Clone data on pull. */
%newobject _ldns_rr_list_rr;
%rename(__ldns_rr_list_rr) ldns_rr_list_rr;
%inline
%{
ldns_rr * _ldns_rr_list_rr(ldns_rr_list *r, int i)
{
ldns_rr *rr;
rr = ldns_rr_list_rr(r, i);
return (rr != NULL) ? ldns_rr_clone(rr) : NULL;
}
%}
%newobject _ldns_rr_list_owner;
%rename(__ldns_rr_list_owner) ldns_rr_list_owner;
%inline
%{
ldns_rdf * _ldns_rr_list_owner(ldns_rr_list *r)
{
ldns_rdf *rdf;
rdf = ldns_rr_list_owner(r);
return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
}
%}
/* End clone data on pull. */
/* ========================================================================= */
/* Debugging related code. */
/* ========================================================================= */
%rename(ldns_rr_list) ldns_struct_rr_list;
#ifdef LDNS_DEBUG
%rename(__ldns_rr_list_deep_free) ldns_rr_list_deep_free;
%rename(__ldns_rr_list_free) ldns_rr_list_free;
%inline
%{
void _ldns_rr_list_deep_free(ldns_rr_list *r)
{
printf("******** LDNS_RR_LIST deep free 0x%lX ************\n",
(long unsigned int) r);
ldns_rr_list_deep_free(r);
}
void _ldns_rr_list_free(ldns_rr_list *r)
{
printf("******** LDNS_RR_LIST deep free 0x%lX ************\n",
(long unsigned int) r);
ldns_rr_list_free(r);
}
%}
#else
%rename(_ldns_rr_list_deep_free) ldns_rr_list_deep_free;
%rename(_ldns_rr_list_free) ldns_rr_list_free;
#endif
/* ========================================================================= */
/* Added C code. */
/* ========================================================================= */
/* None. */
/* ========================================================================= */
/* Encapsulating Python code. */
/* ========================================================================= */
%feature("docstring") ldns_struct_rr_list "List of Resource Records.
This class contains a list of RR's (see :class:`ldns.ldns_rr`).
"
%extend ldns_struct_rr_list {
%pythoncode
%{
def __init__(self):
self.this = _ldns.ldns_rr_list_new()
if not self.this:
raise Exception("Can't create new RR_LIST")
__swig_destroy__ = _ldns._ldns_rr_list_deep_free
#
# LDNS_RR_LIST_CONSTRUCTORS_
#
@staticmethod
def new(raiseException=True):
"""
Creates an empty RR List object.
:param raiseException: Set to True if an exception should
signal an error.
:type raiseException: bool
:throws Exception: when `raiseException` is True and error
occurs.
:return: :class:`ldns_rr_list` Empty RR list.
"""
rrl = _ldns.ldns_rr_list_new()
if (not rrl) and raiseException:
raise Exception("Can't create RR List.")
return rrl
@staticmethod
def new_frm_file(filename="/etc/hosts", raiseException=True):
"""
Creates an RR List object from file content.
Goes through a file and returns a rr list containing
all the defined hosts in there.
:param filename: The filename to use.
:type filename: str
:param raiseException: Set to True if an exception should
signal an error.
:type raiseException: bool
:throws TypeError: when `filename` of inappropriate type.
:throws Exception: when `raiseException` is True and error
occurs.
:return: RR List object or None. If the object can't be
created and `raiseException` is True, an exception occurs.
**Usage**
>>> alist = ldns.ldns_rr_list.new_frm_file()
>>> print alist
localhost. 3600 IN A 127.0.0.1
...
"""
rr = _ldns.ldns_get_rr_list_hosts_frm_file(filename)
if (not rr) and (raiseException):
raise Exception("Can't create RR List.")
return rr
#
# _LDNS_RR_LIST_CONSTRUCTORS
#
def __str__(self):
"""
Converts a list of resource records to presentation format.
:return: (str) Presentation format.
"""
return _ldns.ldns_rr_list2str(self)
def print_to_file(self, output):
"""
Print a rr_list to output.
:param output: Opened file to print to.
:throws TypeError: when `output` of inappropriate type.
"""
_ldns.ldns_rr_list_print(output, self)
def to_canonical(self):
"""
Converts each dname in each rr in a rr_list to its canonical
form.
"""
_ldns.ldns_rr_list2canonical(self)
#parameters: ldns_rr_list *,
#retvals:
def rrs(self):
"""
Returns a generator object of a list of rr records.
:return: (generator) generator object.
"""
for i in range(0, self.rr_count()):
yield self.rr(i)
def is_rrset(self):
"""
Checks if the rr list is a rr set.
:return: (bool) True if rr list is a rr set.
"""
return _ldns.ldns_is_rrset(self)
def __cmp__(self, rrl2):
"""
Compares two rr lists.
:param rrl2: The second one.
:type rrl2: :class:`ldns_rr_list`
:throws TypeError: when `rrl2` of non-:class:`ldns_rr_list`
type.
:return: (int) 0 if equal, -1 if this list comes before
`rrl2`, 1 if `rrl2` comes before this list.
"""
return _ldns.ldns_rr_list_compare(self, rrl2)
def __lt__(self, other):
"""
Compares two rr lists.
:param other: The second one.
:type other: :class:`ldns_rr_list`
:throws TypeError: when `other` of non-:class:`ldns_rr_list`
type.
:return: (bool) True when `self` is less than 'other'.
"""
return _ldns.ldns_rr_list_compare(self, other) == -1
def __le__(self, other):
"""
Compares two rr lists.
:param other: The second one.
:type other: :class:`ldns_rr_list`
:throws TypeError: when `other` of non-:class:`ldns_rr_list`
type.
:return: (bool) True when `self` is less than or equal to
'other'.
"""
return _ldns.ldns_rr_list_compare(self, other) != 1
def __eq__(self, other):
"""
Compares two rr lists.
:param other: The second one.
:type other: :class:`ldns_rr_list`
:throws TypeError: when `other` of non-:class:`ldns_rr_list`
type.
:return: (bool) True when `self` is equal to 'other'.
"""
return _ldns.ldns_rr_list_compare(self, other) == 0
def __ne__(self, other):
"""
Compares two rr lists.
:param other: The second one.
:type other: :class:`ldns_rr_list`
:throws TypeError: when `other` of non-:class:`ldns_rr_list`
type.
:return: (bool) True when `self` is not equal to 'other'.
"""
return _ldns.ldns_rr_list_compare(self, other) != 0
def __gt__(self, other):
"""
Compares two rr lists.
:param other: The second one.
:type other: :class:`ldns_rr_list`
:throws TypeError: when `other` of non-:class:`ldns_rr_list`
type.
:return: (bool) True when `self` is greater than 'other'.
"""
return _ldns.ldns_rr_list_compare(self, other) == 1
def __ge__(self, other):
"""
Compares two rr lists.
:param other: The second one.
:type other: :class:`ldns_rr_list`
:throws TypeError: when `other` of non-:class:`ldns_rr_list`
type.
:return: (bool) True when `self` is greater than or equal to
'other'.
"""
return _ldns.ldns_rr_list_compare(self, other) != -1
def write_to_buffer(self, buffer):
"""
Copies the rr_list data to the buffer in wire format.
:param buffer: Output buffer to append the result to.
:type buffer: :class:`ldns_buffer`
:throws TypeError: when `buffer` of non-:class:`ldns_buffer`
type.
:return: (ldns_status) ldns_status
"""
return _ldns.ldns_rr_list2buffer_wire(buffer, self)
#
# LDNS_RR_LIST_METHODS_
#
def cat(self, right):
"""
Concatenates two ldns_rr_lists together.
This modifies rr list (to extend it and adds RRs from right).
:param right: The right-hand side.
:type right: :class:`ldns_rr_list`
:throws TypeError: when `right` of non-:class:`ldns_rr_list`
type.
:return: (bool) True if success.
"""
return _ldns._ldns_rr_list_cat(self, right)
#parameters: ldns_rr_list *, ldns_rr_list *,
#retvals: bool
def cat_clone(self, right):
"""
Concatenates two ldns_rr_lists together, creates a new list
of the rr's (instead of appending the content to an existing
list).
:param right: The right-hand side.
:type right: :class:`ldns_rr_list`
:throws TypeError: when `right` of non-:class:`ldns_rr_list`
type.
:return: (:class:`ldns_rr_list`) rr list with left-hand side +
right-hand side concatenated, on None on error.
"""
return _ldns.ldns_rr_list_cat_clone(self, right)
#parameters: ldns_rr_list *, ldns_rr_list *,
#retvals: ldns_rr_list *
def clone(self):
"""
Clones an rrlist.
:return: (:class:`ldns_rr_list`) the cloned rr list,
or None on error.
"""
return _ldns.ldns_rr_list_clone(self)
#parameters: const ldns_rr_list *,
#retvals: ldns_rr_list *
def contains_rr(self, rr):
"""
Returns True if the given rr is one of the rrs in the list,
or if it is equal to one.
:param rr: The rr to check.
:type rr: :class:`ldns_rr`
:throws TypeError: when `rr` of non-:class:`ldns_rr` type.
:return: (bool) True if rr_list contains `rr`, False otherwise.
"""
return _ldns.ldns_rr_list_contains_rr(self, rr)
#parameters: const ldns_rr_list *, ldns_rr *,
#retvals: bool
def owner(self):
"""
Returns the owner domain name rdf of the first element of
the RR. If there are no elements present, None is returned.
:return: (:class:`ldns_dname`) dname of the first element,
or None if the list is empty.
"""
rdf = _ldns._ldns_rr_list_owner(self)
if rdf:
rdf = ldns_dname(rdf, clone=False)
return rdf
#parameters: const ldns_rr_list *,
#retvals: ldns_rdf *
def pop_rr(self):
"""
Pops the last rr from an rrlist.
:return: (:class:`ldns_rr`) None if nothing to pop.
Otherwise the popped RR.
"""
rr = _ldns.ldns_rr_list_pop_rr(self)
return rr
#parameters: ldns_rr_list *,
#retvals: ldns_rr *
def pop_rr_list(self, size):
"""
Pops an rr_list of size s from an rrlist.
:param size: The number of rr's to pop.
:type size: positive int
:throws TypeError: when `size` of inappropriate type.
:return: (:class:`ldns_rr_list`) None if nothing to pop.
Otherwise the popped rr list.
"""
return _ldns.ldns_rr_list_pop_rr_list(self, size)
#parameters: ldns_rr_list *, size_t,
#retvals: ldns_rr_list *
def pop_rrset(self):
"""
Pops the first rrset from the list, the list must be sorted,
so that all rr's from each rrset are next to each other.
:return: (:class:`ldns_rr_list`) the first rrset, or None when
empty.
"""
return _ldns.ldns_rr_list_pop_rrset(self)
#parameters: ldns_rr_list *,
#retvals: ldns_rr_list *
def push_rr(self, rr):
"""
Pushes an rr to an rrlist.
:param rr: The rr to push.
:type rr: :class:`ldns_rr`
:throws TypeError: when `rr` of non-:class:`ldns_rr` type.
:return: (bool) False on error, otherwise True.
"""
return _ldns._ldns_rr_list_push_rr(self, rr)
#parameters: ldns_rr_list *, const ldns_rr *,
#retvals: bool
def push_rr_list(self, push_list):
"""
Pushes an rr list to an rr list.
:param push_list: The rr_list to push.
:type push_list: :class:`ldns_rr_list`
:throws TypeError: when `push_list` of non-:class:`ldns_rr_list`
type.
:returns: (bool) False on error, otherwise True.
"""
return _ldns._ldns_rr_list_push_rr_list(self, push_list)
#parameters: ldns_rr_list *, const ldns_rr_list *,
#retvals: bool
def rr(self, nr):
"""
Returns a specific rr of an rrlist.
:param nr: Index of the desired rr.
:type nr: positive int
:throws TypeError: when `nr` of inappropriate type.
:return: (:class:`ldns_rr`) The rr at position `nr`, or None
if failed.
"""
return _ldns._ldns_rr_list_rr(self, nr)
#parameters: const ldns_rr_list *, size_t,
#retvals: ldns_rr *
def rr_count(self):
"""
Returns the number of rr's in an rr_list.
:return: (int) The number of rr's.
"""
return _ldns.ldns_rr_list_rr_count(self)
#parameters: const ldns_rr_list *,
#retvals: size_t
def set_rr(self, r, idx):
"""
Set a rr on a specific index in a ldns_rr_list.
:param r: The rr to set.
:type r: :class:`ldns_rr`
:param idx: Index into the rr_list.
:type idx: positive int
:throws TypeError: when parameters of inappropriate types.
:return: (:class:`ldns_rr`) the old rr which was stored in
the rr_list, or None if the index was too large
to set a specific rr.
"""
return _ldns._ldns_rr_list_set_rr(self, r, idx)
#parameters: ldns_rr_list *, const ldns_rr *, size_t,
#retvals: ldns_rr *
def set_rr_count(self, count):
"""
Sets the number of rr's in an rr_list.
:param count: The number of rr in this list.
:type count: positive int
:throws TypeError: when `count` of non-integer type.
:throws Exception: when `count` out of acceptable range.
.. warning::
Don't use this method unless you really know what you
are doing.
"""
# The function C has a tendency to generate an assertion fail when
# the count exceeds the list's capacity -- therefore the checking
# code.
if isinstance(count, int) and \
((count < 0) or (count > self._rr_capacity)):
raise Exception("Given count %d is out of range " % (count) +
"of the rr list's capacity %d." % (self._rr_capacity))
_ldns.ldns_rr_list_set_rr_count(self, count)
#parameters: ldns_rr_list *, size_t,
#retvals:
def sort(self):
"""
Sorts an rr_list (canonical wire format).
"""
_ldns.ldns_rr_list_sort(self)
#parameters: ldns_rr_list *,
#retvals:
def subtype_by_rdf(self, r, pos):
"""
Return the rr_list which matches the rdf at position field.
Think type-covered stuff for RRSIG.
:param r: The rdf to use for the comparison.
:type r: :class:`ldns_rdf`
:param pos: At which position we can find the rdf.
:type pos: positive int
:throws TypeError: when parameters of inappropriate types.
:return: (:class:`ldns_rr_list`) a new rr list with only
the RRs that match, or None when nothing matches.
"""
return _ldns.ldns_rr_list_subtype_by_rdf(self, r, pos)
#parameters: ldns_rr_list *, ldns_rdf *, size_t,
#retvals: ldns_rr_list *
def type(self):
"""
Returns the type of the first element of the RR.
If there are no elements present, 0 is returned.
:return: (int) rr_type of the first element,
or 0 if the list is empty.
"""
return _ldns.ldns_rr_list_type(self)
#parameters: const ldns_rr_list *,
#retvals: ldns_rr_type
#
# _LDNS_RR_LIST_METHODS
#
%}
}
/* ========================================================================= */
/* SWIG setting and definitions. */
/* ========================================================================= */
%newobject ldns_rr_descript;
%nodefaultctor ldns_struct_rr_descriptor; /* No default constructor. */
%nodefaultdtor ldns_struct_rr_descriptor; /* No default destructor.*/
%rename(ldns_rr_descriptor) ldns_struct_rr_descriptor;
/* ========================================================================= */
/* Debugging related code. */
/* ========================================================================= */
/* None. */
/* ========================================================================= */
/* Added C code. */
/* ========================================================================= */
%inline
%{
/*
* Does nothing, but keeps the SWIG wrapper quiet about absent destructor.
*/
void ldns_rr_descriptor_dummy_free(const ldns_rr_descriptor *rd)
{
(void) rd;
}
%}
/* ========================================================================= */
/* Encapsulating Python code. */
/* ========================================================================= */
%feature("docstring") ldns_struct_rr_descriptor "Resource Record descriptor.
This structure contains, for all rr types, the rdata fields that are defined.
In order to create a class instance use :meth:`ldns_rr_descriptor`.
"
%extend ldns_struct_rr_descriptor {
%pythoncode
%{
def __init__(self, rr_type):
"""
Returns the resource record descriptor for the given type.
:param rr_type: RR type.
:type rr_type: int
:throws TypeError: when `rr_type` of inappropriate type.
:return: (:class:`ldns_rr_descriptor`) RR descriptor class.
"""
self.this = self.ldns_rr_descriptor(rr_type)
def __str__(self):
raise Exception("The content of this class cannot be printed.")
__swig_destroy__ = _ldns.ldns_rr_descriptor_dummy_free
#
# LDNS_RR_DESCRIPTOR_CONSTRUCTORS_
#
@staticmethod
def ldns_rr_descriptor(rr_type):
"""
Returns the resource record descriptor for the given type.
:param rr_type: RR type.
:type rr_type: int
:throws TypeError: when `rr_type` of inappropriate type.
:return: (:class:`ldns_rr_descriptor`) RR descriptor class.
"""
return _ldns.ldns_rr_descript(rr_type)
#parameters: uint16_t
#retvals: const ldns_rr_descriptor *
#
# _LDNS_RR_DESCRIPTOR_CONSTRUCTORS
#
#
# LDNS_RR_DESCRIPTOR_METHODS_
#
def field_type(self, field):
"""
Returns the rdf type for the given rdata field number of the
rr type for the given descriptor.
:param field: The field number.
:type field: positive int
:throws TypeError: when `field` of non-inetger type.
:return: (int) the rdf type for the field.
"""
return _ldns.ldns_rr_descriptor_field_type(self, field)
#parameters: const ldns_rr_descriptor *, size_t,
#retvals: ldns_rdf_type
def maximum(self):
"""
Returns the maximum number of rdata fields of the rr type this
descriptor describes.
:return: (int) the maximum number of rdata fields.
"""
return _ldns.ldns_rr_descriptor_maximum(self)
#parameters: const ldns_rr_descriptor *,
#retvals: size_t
def minimum(self):
"""
Returns the minimum number of rdata fields of the rr type this
descriptor describes.
:return: (int) the minimum number of rdata fields.
"""
return _ldns.ldns_rr_descriptor_minimum(self)
#parameters: const ldns_rr_descriptor *,
#retvals: size_t
#
# _LDNS_RR_DESCRIPTOR_METHODS
#
%}
}
/* ========================================================================= */
/* Added C code. */
/* ========================================================================= */
/*
* rrsig checking wrappers
*
* Copying of rr pointers into the good_keys list leads to double free
* problems, therefore we provide two options - either ignore the keys
* or get list of indexes of the keys. The latter allows fetching of the
* keys later on from the original key set.
*/
%rename(__ldns_verify_rrsig_keylist) ldns_verify_rrsig_keylist;
%inline
%{
ldns_status ldns_verify_rrsig_keylist_status_only(ldns_rr_list *rrset,
ldns_rr *rrsig, const ldns_rr_list *keys)
{
ldns_rr_list *good_keys = ldns_rr_list_new();
ldns_status status = ldns_verify_rrsig_keylist(rrset, rrsig, keys,
good_keys);
ldns_rr_list_free(good_keys);
return status;
}
%}
%rename(__ldns_verify_rrsig_keylist) ldns_verify_rrsig_keylist;
%inline
%{
PyObject* ldns_verify_rrsig_keylist_(ldns_rr_list *rrset,
ldns_rr *rrsig, const ldns_rr_list *keys)
{
PyObject* tuple;
PyObject* keylist;
ldns_rr_list *good_keys = ldns_rr_list_new();
ldns_status status = ldns_verify_rrsig_keylist(rrset, rrsig, keys,
good_keys);
tuple = PyTuple_New(2);
PyTuple_SetItem(tuple, 0, SWIG_From_int(status));
keylist = PyList_New(0);
if (status == LDNS_STATUS_OK) {
unsigned int i;
for (i = 0; i < ldns_rr_list_rr_count(keys); i++) {
if (ldns_rr_list_contains_rr(good_keys, ldns_rr_list_rr(keys, i))) {
PyList_Append(keylist, SWIG_From_int(i));
}
}
}
PyTuple_SetItem(tuple, 1, keylist);
ldns_rr_list_free(good_keys);
return tuple;
}
%}
%rename(__ldns_verify_rrsig_keylist_notime) ldns_verify_rrsig_keylist_notime;
%inline
%{
ldns_status ldns_verify_rrsig_keylist_notime_status_only(ldns_rr_list *rrset,
ldns_rr *rrsig, const ldns_rr_list *keys)
{
ldns_rr_list *good_keys = ldns_rr_list_new();
ldns_status status = ldns_verify_rrsig_keylist_notime(rrset, rrsig, keys,
good_keys);
ldns_rr_list_free(good_keys);
return status;
}
%}
%rename(__ldns_verify_rrsig_keylist_notime) ldns_verify_rrsig_keylist_notime;
%inline
%{
PyObject* ldns_verify_rrsig_keylist_notime_(ldns_rr_list *rrset,
ldns_rr *rrsig, const ldns_rr_list *keys)
{
PyObject* tuple;
PyObject* keylist;
ldns_rr_list *good_keys = ldns_rr_list_new();
ldns_status status = ldns_verify_rrsig_keylist_notime(rrset, rrsig, keys,
good_keys);
tuple = PyTuple_New(2);
PyTuple_SetItem(tuple, 0, SWIG_From_int(status));
keylist = PyList_New(0);
if (status == LDNS_STATUS_OK) {
unsigned int i;
for (i = 0; i < ldns_rr_list_rr_count(keys); i++) {
if (ldns_rr_list_contains_rr(good_keys, ldns_rr_list_rr(keys, i))) {
PyList_Append(keylist, SWIG_From_int(i));
}
}
}
PyTuple_SetItem(tuple, 1, keylist);
ldns_rr_list_free(good_keys);
return tuple;
}
%}
/* End of rrsig checking wrappers. */
|