19 #ifdef HAVE_SYS_SOCKET_H
20 #include <sys/socket.h>
22 #ifdef HAVE_ARPA_INET_H
23 #include <arpa/inet.h>
32 #include <openssl/bn.h>
33 #include <openssl/rsa.h>
35 #include <openssl/dsa.h>
39 #ifndef INET_ADDRSTRLEN
40 #define INET_ADDRSTRLEN 16
42 #ifndef INET6_ADDRSTRLEN
43 #define INET6_ADDRSTRLEN 46
203 if (lt && lt->
name) {
208 return ldns_buffer_status(output);
215 if (lt && lt->
name) {
220 return ldns_buffer_status(output);
229 if (lt && lt->
name) {
234 return ldns_buffer_status(output);
243 if (lt && lt->
name) {
249 return ldns_buffer_status(output);
360 for(i = 0; i < len; i++) {
364 c = (
unsigned char) data[src_pos];
365 if(c ==
'.' || c ==
';' ||
366 c ==
'(' || c ==
')' ||
370 }
else if (!(isascii(c) && isgraph(c))) {
385 return ldns_buffer_status(output);
393 return ldns_buffer_status(output);
401 return ldns_buffer_status(output);
409 return ldns_buffer_status(output);
419 memset(&tm, 0,
sizeof(tm));
421 && strftime(date_buf, 15,
"%Y%m%d%H%M%S", &tm)) {
424 return ldns_buffer_status(output);
435 return ldns_buffer_status(output);
447 return ldns_buffer_status(output);
452 size_t amount,
const uint8_t* characters)
457 if (isprint((
int)ch) || ch ==
'\t') {
458 if (ch ==
'\"' || ch ==
'\\')
464 (
unsigned)(uint8_t) ch);
480 ldns_characters2buffer_str(output,
483 return ldns_buffer_status(output);
494 return ldns_buffer_status(output);
505 return ldns_buffer_status(output);
526 return ldns_buffer_status(output);
537 return ldns_buffer_status(output);
546 if (! ldns_output_format_covers_type(fmt, data) &&
554 return ldns_buffer_status(output);
560 return ldns_rdf2buffer_str_type_fmt(output,
576 return ldns_buffer_status(output);
590 return ldns_buffer_status(output);
600 loc_cm_print(
ldns_buffer *output, uint8_t mantissa, uint8_t exponent)
612 for(i=0; i<exponent-2; i++)
640 if (descriptor && descriptor->
_name) {
646 return ldns_buffer_status(output);
682 return ldns_buffer_status(output);
710 uint8_t horizontal_precision;
711 uint8_t vertical_precision;
715 char latitude_hemisphere;
716 char longitude_hemisphere;
721 uint32_t equator = (uint32_t) ldns_power(2, 31);
739 if (latitude > equator) {
740 latitude_hemisphere =
'N';
741 latitude = latitude - equator;
743 latitude_hemisphere =
'S';
744 latitude = equator - latitude;
746 h = latitude / (1000 * 60 * 60);
747 latitude = latitude % (1000 * 60 * 60);
748 m = latitude / (1000 * 60);
749 latitude = latitude % (1000 * 60);
750 s = (double) latitude / 1000.0;
752 h, m, s, latitude_hemisphere);
754 if (longitude > equator) {
755 longitude_hemisphere =
'E';
756 longitude = longitude - equator;
758 longitude_hemisphere =
'W';
759 longitude = equator - longitude;
761 h = longitude / (1000 * 60 * 60);
762 longitude = longitude % (1000 * 60 * 60);
763 m = longitude / (1000 * 60);
764 longitude = longitude % (1000 * 60);
765 s = (double) longitude / (1000.0);
767 h, m, s, longitude_hemisphere);
769 s = ((double) altitude) / 100;
772 if(altitude%100 != 0)
779 loc_cm_print(output, (size & 0xf0) >> 4, size & 0x0f);
782 loc_cm_print(output, (horizontal_precision & 0xf0) >> 4,
783 horizontal_precision & 0x0f);
786 loc_cm_print(output, (vertical_precision & 0xf0) >> 4,
787 vertical_precision & 0x0f);
790 return ldns_buffer_status(output);
820 struct protoent *protocol;
821 char *proto_name = NULL;
823 struct servent *service;
824 uint16_t current_service;
830 protocol = getprotobynumber((
int) protocol_nr);
831 if (protocol && (protocol->p_name != NULL)) {
832 proto_name = protocol->p_name;
838 for (current_service = 0;
839 current_service < (
ldns_rdf_size(rdf)-1)*8; current_service++) {
841 service = getservbyport((
int) htons(current_service),
843 if (service && service->s_name) {
848 #ifdef HAVE_ENDSERVENT
853 if(current_service == 65535) {
break; }
856 #ifdef HAVE_ENDPROTOENT
860 return ldns_buffer_status(output);
870 uint8_t window_block_nr;
871 uint8_t bitmap_length;
878 window_block_nr = data[pos];
879 bitmap_length = data[pos + 1];
884 for (bit_pos = 0; bit_pos < (bitmap_length) * 8; bit_pos++) {
888 type = 256 * (uint16_t) window_block_nr + bit_pos;
890 if (! ldns_output_format_covers_type(fmt, type) &&
900 pos += (uint16_t) bitmap_length;
902 return ldns_buffer_status(output);
908 return ldns_rdf2buffer_str_nsec_fmt(output,
923 salt_length = data[0];
925 if (salt_length == 0 || ((
size_t)salt_length)+1 >
ldns_rdf_size(rdf)) {
928 for (salt_pos = 0; salt_pos < salt_length; salt_pos++) {
934 return ldns_buffer_status(output);
945 return ldns_buffer_status(output);
952 uint64_t tsigtime = 0;
954 uint64_t d0, d1, d2, d3, d4, d5;
965 tsigtime = (d0<<40) | (d1<<32) | (d2<<24) | (d3<<16) | (d4<<8) | d5;
969 return ldns_buffer_status(output);
976 uint16_t address_family;
986 address_family = ldns_read_uint16(&data[pos]);
987 prefix = data[pos + 2];
997 for (i = 0; i < 4; i++) {
1001 if (i < (
unsigned short) adf_length) {
1018 for (i = 0; i < 16; i++) {
1019 if (i % 2 == 0 && i > 0) {
1022 if (i < (
unsigned short) adf_length) {
1036 "Unknown address family: %u data: ",
1038 for (i = 1; i < (
unsigned short) (4 + adf_length); i++) {
1044 pos += 4 + adf_length;
1046 return ldns_buffer_status(output);
1058 size = ldns_b64_ntop_calculate_size(
ldns_rdf_size(rdf) - 2);
1073 return ldns_buffer_status(output);
1084 uint8_t gateway_type;
1088 uint8_t *gateway_data;
1090 size_t public_key_size;
1091 uint8_t *public_key_data;
1100 precedence = data[0];
1101 gateway_type = data[1];
1102 algorithm = data[2];
1105 switch (gateway_type) {
1158 public_key_data =
LDNS_XMALLOC(uint8_t, public_key_size);
1159 if(!public_key_data) {
1163 memcpy(public_key_data, &data[offset], public_key_size);
1165 public_key_size, public_key_data);
1183 return ldns_buffer_status(output);
1197 return ldns_buffer_status(output);
1210 return ldns_buffer_status(output);
1224 return ldns_buffer_status(output);
1231 const uint8_t* chars;
1242 while (nchars > 0) {
1243 ch = (char)*chars++;
1244 if (! isalnum((
unsigned char)ch)) {
1250 return ldns_buffer_status(output);
1258 ldns_characters2buffer_str(output,
1261 return ldns_buffer_status(output);
1276 if ((hit_size = data[0]) == 0 ||
1277 (pk_size = ldns_read_uint16(data + 2)) == 0 ||
1278 rdf_size < (
size_t) hit_size + pk_size + 4) {
1285 for (data += 4; hit_size > 0; hit_size--, data++) {
1289 ldns_buffer_write_char(output, (uint8_t)
' ');
1292 ldns_b64_ntop_calculate_size(pk_size))) {
1295 (
char *) ldns_buffer_current(output),
1296 ldns_buffer_remaining(output));
1299 written < (
int) ldns_buffer_remaining(output)) {
1304 return ldns_buffer_status(output);
1316 uint8_t discovery_optional;
1320 uint8_t *relay_data;
1328 precedence = data[0];
1329 discovery_optional = ((data[1] & 0x80) >> 7);
1330 relay_type = data[1] & 0x7F;
1333 switch (relay_type) {
1386 precedence, discovery_optional, relay_type);
1391 return ldns_buffer_status(output);
1394 #ifdef RRTYPE_SVCB_HTTPS
1398 svcparam_mandatory2buffer_str(
ldns_buffer *output,
size_t sz, uint8_t *data)
1404 for (data += 2, sz -= 2; sz; data += 2, sz -= 2) {
1405 ldns_buffer_write_char(output,
',');
1408 return ldns_buffer_status(output);
1412 svcparam_alpn2buffer_str(
ldns_buffer *output,
size_t sz, uint8_t *data)
1414 uint8_t *eod = data + sz, *dp;
1418 for (dp = data; dp < eod && !quote; dp += 1 + *dp) {
1419 if (dp + 1 + *dp > eod)
1422 for (i = 0; i < *dp; i++)
1423 if (isspace(dp[i + 1]))
1428 ldns_buffer_write_char(output,
'"');
1429 while (data < eod) {
1430 uint8_t *eot = data + 1 + *data;
1435 if (eod - data < (
int)sz)
1436 ldns_buffer_write_char(output,
',');
1438 for (data += 1; data < eot; data += 1) {
1441 if (isprint(ch) || ch ==
'\t') {
1442 if (ch ==
'"' || ch ==
',' || ch ==
'\\')
1443 ldns_buffer_write_char(output,
'\\');
1444 ldns_buffer_write_char(output, ch);
1451 ldns_buffer_write_char(output,
'"');
1452 return ldns_buffer_status(output);
1456 svcparam_port2buffer_str(
ldns_buffer *output,
size_t sz, uint8_t *data)
1461 return ldns_buffer_status(output);
1465 svcparam_ipv4hint2buffer_str(
ldns_buffer *output,
size_t sz, uint8_t *data)
1472 ldns_buffer_write_chars(output, str);
1474 for (data += 4, sz -= 4; sz ; data += 4, sz -= 4 ) {
1475 ldns_buffer_write_char(output,
',');
1479 ldns_buffer_write_chars(output, str);
1481 return ldns_buffer_status(output);
1485 svcparam_ech2buffer_str(
ldns_buffer *output,
size_t sz, uint8_t *data)
1487 size_t str_sz = ldns_b64_ntop_calculate_size(sz);
1494 , (
char *)ldns_buffer_current(output), str_sz);
1496 ldns_buffer_skip(output, written);
1500 return ldns_buffer_status(output);
1504 svcparam_ipv6hint2buffer_str(
ldns_buffer *output,
size_t sz, uint8_t *data)
1511 ldns_buffer_write_chars(output, str);
1513 for (data += 16, sz -= 16; sz ; data += 16, sz -= 16) {
1514 ldns_buffer_write_char(output,
',');
1518 ldns_buffer_write_chars(output, str);
1520 return ldns_buffer_status(output);
1524 svcparam_value2buffer_str(
ldns_buffer *output,
size_t sz, uint8_t *data)
1526 uint8_t *eod = data + sz, *dp;
1529 for (dp = data; dp < eod && !isspace(*dp); dp++)
1532 if ((quote = dp < eod))
1533 ldns_buffer_write_char(output,
'"');
1535 for (dp = data; dp < eod; dp++) {
1538 if (isprint(ch) || ch ==
'\t') {
1539 if (ch ==
'"' || ch ==
'\\')
1540 ldns_buffer_write_char(output,
'\\');
1541 ldns_buffer_write_char(output, ch);
1546 ldns_buffer_write_char(output,
'"');
1547 return ldns_buffer_status(output);
1553 uint8_t *data, *dp, *next_dp = NULL;
1564 for (dp = data; dp + 4 <= data + sz; dp = next_dp) {
1566 uint16_t val_sz = ldns_read_uint16(dp + 2);
1568 if ((next_dp = dp + 4 + val_sz) > data + sz)
1572 ldns_buffer_write_char(output,
' ');
1580 ldns_buffer_write_char(output,
'=');
1583 st = svcparam_mandatory2buffer_str(output, val_sz, dp);
1586 st = svcparam_alpn2buffer_str(output, val_sz, dp);
1591 st = svcparam_port2buffer_str(output, val_sz, dp);
1594 st = svcparam_ipv4hint2buffer_str(output, val_sz, dp);
1597 st = svcparam_ech2buffer_str(output, val_sz, dp);
1600 st = svcparam_ipv6hint2buffer_str(output, val_sz, dp);
1603 st = svcparam_value2buffer_str(output, val_sz, dp);
1609 return ldns_buffer_status(output);
1615 (void)output; (void)rdf;
1675 res = ldns_rdf2buffer_str_nsec_fmt(buffer, fmt, rdf);
1681 res = ldns_rdf2buffer_str_type_fmt(buffer, fmt, rdf);
1757 ldns_b32_ext2dname(
const ldns_rdf *rdf)
1765 size = ldns_b32_ntop_calculate_size(
ldns_rdf_size(rdf) - 1);
1786 size_t total_rdfsize = 0;
1793 if (total_rdfsize == 0) {
1795 return ldns_buffer_status(output);
1805 return ldns_buffer_status(output);
1816 if (fmt_st == NULL) {
1825 return ldns_buffer_status(output);
1847 return ldns_rr2buffer_str_rfc3597(output, rr);
1879 status = ldns_buffer_status(output);
1886 (
unsigned long) ldns_read_uint32(
1888 status = ldns_buffer_status(output);
1890 status = ldns_rdf2buffer_str_fmt(output,
1927 }
else if (fmt_st->
flags
2001 key = ldns_b32_ext2dname(
2029 return ldns_buffer_status(output);
2048 return ldns_buffer_status(output);
2107 return ldns_buffer_status(output);
2113 ldns_edns_hex_data2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2116 for (j = 0; j < len; j++) {
2122 ldns_edns_llq2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2125 const char* llq_errors[] = {
"NO-ERROR",
"SERV-FULL",
"STATIC",
2126 "FORMAT-ERR",
"NO-SUCH-LLQ",
"BAD-VERS",
"UNKNOWN_ERR"};
2127 const unsigned int llq_errors_num = 7;
2128 const char* llq_opcodes[] = {
"LLQ-SETUP",
"LLQ-REFRESH",
"LLQ-EVENT"};
2129 const unsigned int llq_opcodes_num = 3;
2131 uint16_t version, llq_opcode, error_code;
2133 uint32_t lease_life;
2140 ldns_edns_hex_data2buffer_str(output, data, len);
2142 return ldns_buffer_status(output);
2144 version = ldns_read_uint16(data);
2145 llq_opcode = ldns_read_uint16(data+2);
2146 error_code = ldns_read_uint16(data+4);
2147 memmove(&llq_id, data+6,
sizeof(uint64_t));
2148 lease_life = ldns_read_uint32(data+14);
2153 if(llq_opcode < llq_opcodes_num) {
2159 if(error_code < llq_errors_num)
2167 (
unsigned long long)llq_id, (
unsigned long)lease_life);
2170 (
unsigned long long)llq_id, (
unsigned long)lease_life);
2172 return ldns_buffer_status(output);
2177 ldns_edns_ul2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2185 ldns_edns_hex_data2buffer_str(output, data, len);
2186 return ldns_buffer_status(output);
2188 lease = ldns_read_uint32(data);
2191 return ldns_buffer_status(output);
2195 ldns_edns_nsid2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2197 size_t i, printed=0;
2200 ldns_edns_hex_data2buffer_str(output, data, len);
2203 for(i = 0; i < len; i++) {
2204 if(isprint((
unsigned char)data[i]) || data[i] ==
'\t') {
2214 return ldns_buffer_status(output);
2219 ldns_edns_dau2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2226 for(i = 0; i <len; i++) {
2228 if (lt && lt->
name) {
2234 return ldns_buffer_status(output);
2238 ldns_edns_dhu2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2245 for(i = 0; i < len; i++) {
2247 if (lt && lt->
name) {
2253 return ldns_buffer_status(output);
2257 ldns_edns_d3u2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2263 for(i=0; i<len; i++) {
2270 return ldns_buffer_status(output);
2274 ldns_edns_subnet2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2277 uint8_t source, scope;
2283 ldns_edns_hex_data2buffer_str(output, data, len);
2284 return ldns_buffer_status(output);
2288 family = ldns_read_uint16(data);
2295 memset(ip4, 0,
sizeof(ip4));
2298 ldns_edns_hex_data2buffer_str(output, data+4+4, len-4-4);
2302 memmove(ip4, data+4, len-4);
2303 if(!inet_ntop(AF_INET, ip4, buf, (socklen_t)
sizeof(buf))) {
2305 ldns_edns_hex_data2buffer_str(output, data+4+4, len-4-4);
2309 }
else if(family == 2) {
2313 memset(ip6, 0,
sizeof(ip6));
2316 ldns_edns_hex_data2buffer_str(output, data+4+16, len-4-16);
2320 memmove(ip6, data+4, len-4);
2322 if(!inet_ntop(AF_INET6, ip6, buf, (socklen_t)
sizeof(buf))) {
2324 ldns_edns_hex_data2buffer_str(output, data+4+4, len-4-4);
2329 ldns_edns_hex_data2buffer_str(output, data+4+4, len-4-4);
2334 ldns_edns_hex_data2buffer_str(output, data, len);
2338 return ldns_buffer_status(output);
2342 ldns_edns_expire2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2347 if (!(len == 0) || len == 4) {
2349 ldns_edns_hex_data2buffer_str(output, data, len);
2351 return ldns_buffer_status(output);
2355 ldns_edns_hex_data2buffer_str(output, data, len);
2357 return ldns_buffer_status(output);
2362 ldns_edns_cookie2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2367 if (!(len == 8 || (len >= 16 && len < 40))) {
2369 ldns_edns_hex_data2buffer_str(output, data, len);
2371 ldns_edns_hex_data2buffer_str(output, data, len);
2373 return ldns_buffer_status(output);
2377 ldns_edns_keepalive2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2383 if(!(len == 0 || len == 2)) {
2385 ldns_edns_hex_data2buffer_str(output, data, len);
2387 return ldns_buffer_status(output);
2393 timeout = ldns_read_uint16(data);
2396 return ldns_buffer_status(output);
2400 ldns_edns_padding2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2403 ldns_edns_hex_data2buffer_str(output, data, len);
2405 return ldns_buffer_status(output);
2409 ldns_edns_chain2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2417 ldns_edns_hex_data2buffer_str(output, data, len);
2419 return ldns_buffer_status(output);
2422 ldns_characters2buffer_str(output, len, data);
2424 return ldns_buffer_status(output);
2428 ldns_edns_key_tag2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2434 if(len < 2 || len % 2 != 0) {
2436 ldns_edns_hex_data2buffer_str(output, data, len);
2438 return ldns_buffer_status(output);
2441 for (i = 0; i < len; i += 2) {
2442 uint16_t tag = ldns_read_uint16(data);
2447 return ldns_buffer_status(output);
2451 ldns_edns_ede2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2459 ldns_edns_hex_data2buffer_str(output, data, len);
2461 return ldns_buffer_status(output);
2464 ede = ldns_read_uint16(data);
2561 for (i = 0; i < len; i++) {
2567 ldns_characters2buffer_str(output, len, data);
2571 return ldns_buffer_status(output);
2575 ldns_edns_client_tag2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2581 ldns_edns_hex_data2buffer_str(output, data, len);
2583 return ldns_buffer_status(output);
2586 ldns_edns_hex_data2buffer_str(output, data, len);
2588 return ldns_buffer_status(output);
2592 ldns_edns_server_tag2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2598 ldns_edns_hex_data2buffer_str(output, data, len);
2600 return ldns_buffer_status(output);
2603 ldns_edns_hex_data2buffer_str(output, data, len);
2605 return ldns_buffer_status(output);
2615 for (i = 0; i < count; i++) {
2629 ldns_edns_llq2buffer_str(output, data, size);
2632 ldns_edns_ul2buffer_str(output, data, size);
2635 ldns_edns_nsid2buffer_str(output, data, size);
2638 ldns_edns_dau2buffer_str(output, data, size);
2641 ldns_edns_dhu2buffer_str(output, data, size);
2644 ldns_edns_d3u2buffer_str(output, data, size);
2647 ldns_edns_subnet2buffer_str(output, data, size);
2650 ldns_edns_expire2buffer_str(output, data, size);
2653 ldns_edns_cookie2buffer_str(output, data, size);
2656 ldns_edns_keepalive2buffer_str(output, data, size);
2659 ldns_edns_padding2buffer_str(output, data, size);
2662 ldns_edns_chain2buffer_str(output, data, size);
2665 ldns_edns_key_tag2buffer_str(output, data, size);
2668 ldns_edns_ede2buffer_str(output, data, size);
2671 ldns_edns_client_tag2buffer_str(output, data, size);
2674 ldns_edns_server_tag2buffer_str(output, data, size);
2678 ldns_edns_hex_data2buffer_str(output, data, size);
2684 return ldns_buffer_status(output);
2695 struct timeval time;
2704 if (!ldns_buffer_status_ok(output)) {
2705 return ldns_buffer_status(output);
2771 ";; EDNS: version %u; flags:",
2814 time_tt = (time_t)time.tv_sec;
2816 (
char*)ctime(&time_tt));
2850 #if defined(HAVE_SSL) && defined(USE_GOST)
2852 ldns_gost_key2buffer_str(
ldns_buffer *output, EVP_PKEY *p)
2854 unsigned char* pp = NULL;
2861 ret = i2d_PrivateKey(p, &pp);
2872 #if defined(HAVE_SSL) && defined(USE_ED25519)
2874 ldns_ed25519_key2buffer_str(
ldns_buffer *output, EVP_PKEY *p)
2876 unsigned char* pp = NULL;
2883 ret = i2d_PrivateKey(p, &pp);
2885 if(ret != 16 + 32) {
2890 (
size_t)ret-16, pp+16);
2900 #if defined(HAVE_SSL) && defined(USE_ED448)
2902 ldns_ed448_key2buffer_str(
ldns_buffer *output, EVP_PKEY *p)
2904 unsigned char* pp = NULL;
2911 ret = i2d_PrivateKey(p, &pp);
2913 if(ret != 16 + 57) {
2918 (
size_t)ret-16, pp+16);
2928 #if defined(HAVE_SSL)
2931 ldns_print_bignum_b64_line(
ldns_buffer* output,
const char* label,
const BIGNUM* num)
2934 if(!bignumbuf)
return 0;
2939 int i = BN_bn2bin(num, bignumbuf);
2964 unsigned char *bignum;
2981 if (ldns_buffer_status_ok(output)) {
2997 "Algorithm: %u (RSA)\n",
3002 "Algorithm: %u (RSASHA1)\n",
3007 "Algorithm: %u (RSASHA1_NSEC3)\n",
3013 "Algorithm: %u (RSASHA256)\n",
3018 "Algorithm: %u (RSASHA512)\n",
3024 fprintf(stderr,
"Warning: unknown signature ");
3026 "algorithm type %u\n",
3030 "Algorithm: %u (Unknown)\n",
3040 const BIGNUM *n=NULL, *e=NULL, *d=NULL,
3041 *p=NULL, *q=NULL, *dmp1=NULL,
3042 *dmq1=NULL, *iqmp=NULL;
3043 #if OPENSSL_VERSION_NUMBER < 0x10100000 || (defined(HAVE_LIBRESSL) && LIBRESSL_VERSION_NUMBER < 0x20700000)
3053 RSA_get0_key(rsa, &n, &e, &d);
3054 RSA_get0_factors(rsa, &p, &q);
3055 RSA_get0_crt_params(rsa, &dmp1,
3058 if(!ldns_print_bignum_b64_line(output,
"Modulus", n))
3060 if(!ldns_print_bignum_b64_line(output,
"PublicExponent", e))
3062 if(!ldns_print_bignum_b64_line(output,
"PrivateExponent", d))
3064 if(!ldns_print_bignum_b64_line(output,
"Prime1", p))
3066 if(!ldns_print_bignum_b64_line(output,
"Prime2", q))
3068 if(!ldns_print_bignum_b64_line(output,
"Exponent1", dmp1))
3070 if(!ldns_print_bignum_b64_line(output,
"Exponent2", dmq1))
3072 if(!ldns_print_bignum_b64_line(output,
"Coefficient", iqmp))
3094 const BIGNUM *p=NULL, *q=NULL, *g=NULL,
3095 *priv_key=NULL, *pub_key=NULL;
3096 #if OPENSSL_VERSION_NUMBER < 0x10100000 || (defined(HAVE_LIBRESSL) && LIBRESSL_VERSION_NUMBER < 0x20700000)
3101 priv_key = dsa->priv_key;
3102 pub_key = dsa->pub_key;
3105 DSA_get0_pqg(dsa, &p, &q, &g);
3106 DSA_get0_key(dsa, &pub_key, &priv_key);
3108 if(!ldns_print_bignum_b64_line(output,
"Prime(p)", p))
3110 if(!ldns_print_bignum_b64_line(output,
"Subprime(q)", q))
3112 if(!ldns_print_bignum_b64_line(output,
"Base(g)", g))
3114 if(!ldns_print_bignum_b64_line(output,
"Private_value(x)", priv_key))
3116 if(!ldns_print_bignum_b64_line(output,
"Public_value(y)", pub_key))
3123 #if defined(HAVE_SSL) && defined(USE_GOST)
3126 status = ldns_gost_key2buffer_str(output,
3146 EC_KEY* ec = EVP_PKEY_get1_EC_KEY(k->
_key.
key);
3147 const BIGNUM* b = EC_KEY_get0_private_key(ec);
3148 if(!ldns_print_bignum_b64_line(output,
"PrivateKey", b))
3166 status = ldns_ed25519_key2buffer_str(output,
3177 status = ldns_ed448_key2buffer_str(output,
3186 status = ldns_hmac_key2buffer_str(output, k);
3191 status = ldns_hmac_key2buffer_str(output, k);
3196 status = ldns_hmac_key2buffer_str(output, k);
3201 status = ldns_hmac_key2buffer_str(output, k);
3206 status = ldns_hmac_key2buffer_str(output, k);
3211 status = ldns_hmac_key2buffer_str(output, k);
3217 return ldns_buffer_status(output);
3241 if (*(ldns_buffer_at(buffer, ldns_buffer_position(buffer))) != 0) {
3245 ldns_buffer_write_char(buffer, (uint8_t)
'\0');
3251 str = strdup((
const char *)ldns_buffer_begin(buffer));
3268 ldns_buffer_write_char(buffer, 0);
3278 char *result = NULL;
3295 char *result = NULL;
3319 char *result = NULL;
3344 char *result = NULL;
3361 char *result = NULL;
3369 tmp_buffer, fmt, list)
3398 fprintf(output,
"%s", str);
3400 fprintf(output,
";Unable to convert rdf to string\n");
3411 fprintf(output,
"%s", str);
3413 fprintf(output,
";Unable to convert rr to string\n");
3430 fprintf(output,
"%s", str);
3432 fprintf(output,
";Unable to convert packet to string\n");
3489 fprintf(output,
"trust anchors (%d listed):\n",
3492 fprintf(output,
"tsig: %s %s\n",
3497 fprintf(output,
"default domain: ");
3499 fprintf(output,
"\n");
3504 fprintf(output,
"\t");
3506 fprintf(output,
"\n");
3512 fprintf(output,
"\t");
3515 switch ((
int)rtt[i]) {
3517 fprintf(output,
" - reachable\n");
3520 fprintf(output,
" - unreachable\n");
void ldns_buffer_free(ldns_buffer *buffer)
frees the buffer.
signed char ldns_buffer_set_capacity(ldns_buffer *buffer, size_t capacity)
changes the buffer's capacity.
signed char ldns_buffer_reserve(ldns_buffer *buffer, size_t amount)
ensures BUFFER can contain at least AMOUNT more bytes.
ldns_buffer * ldns_buffer_new(size_t capacity)
creates a new buffer with the specified capacity.
int ldns_buffer_printf(ldns_buffer *buffer, const char *format,...)
prints to the buffer, increasing the capacity if required using buffer_reserve().
void * ldns_buffer_export(ldns_buffer *buffer)
Makes the buffer fixed and returns a pointer to the data.
int ldns_b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize)
ldns_rdf * ldns_dname_label(const ldns_rdf *rdf, uint8_t labelpos)
look inside the rdf and if it is an LDNS_RDF_TYPE_DNAME try and retrieve a specific label.
signed char ldns_nsec_bitmap_covers_type(const ldns_rdf *bitmap, ldns_rr_type type)
Check if RR type t is enumerated and set in the RR type bitmap rdf.
uint16_t ldns_calc_keytag(const ldns_rr *key)
calculates a keytag of a key for use in DNSSEC.
signed char ldns_nsec3_optout(const ldns_rr *nsec3_rr)
Returns true if the opt-out flag has been set in the given NSEC3 RR.
ldns_status ldns_nsec_bitmap_set_type(ldns_rdf *bitmap, ldns_rr_type type)
Checks if RR type t is enumerated in the type bitmap rdf and sets the bit.
ldns_status ldns_nsec_bitmap_clear_type(ldns_rdf *bitmap, ldns_rr_type type)
Checks if RR type t is enumerated in the type bitmap rdf and clears the bit.
ldns_rdf * ldns_nsec3_next_owner(const ldns_rr *nsec3_rr)
Returns the first label of the next ownername in the NSEC3 chain (ie.
ldns_rdf * ldns_dnssec_name_name(const ldns_dnssec_name *name)
Returns the domain name of the given dnssec_name structure.
@ LDNS_EDE_DNSSEC_INDETERMINATE
@ LDNS_EDE_UNSUPPORTED_DNSKEY_ALG
@ LDNS_EDE_RRSIGS_MISSING
@ LDNS_EDE_NO_REACHABLE_AUTHORITY
@ LDNS_EDE_SIGNATURE_EXPIRED
@ LDNS_EDE_STALE_NXDOMAIN_ANSWER
@ LDNS_EDE_NO_ZONE_KEY_BIT_SET
@ LDNS_EDE_DNSKEY_MISSING
@ LDNS_EDE_SIGNATURE_EXPIRED_BEFORE_VALID
@ LDNS_EDE_NOT_AUTHORITATIVE
@ LDNS_EDE_SIGNATURE_NOT_YET_VALID
@ LDNS_EDE_UNSUPPORTED_DS_DIGEST
uint8_t * ldns_edns_get_data(const ldns_edns_option *edns)
returns the EDNS option data.
enum ldns_enum_edns_option ldns_edns_option_code
ldns_edns_option * ldns_edns_option_list_get_option(const ldns_edns_option_list *options_list, size_t index)
returns the EDNS option as the specified index in the list of EDNS options.
ldns_edns_option_code ldns_edns_get_code(const ldns_edns_option *edns)
returns the option code of the EDNS data.
void ldns_edns_option_list_deep_free(ldns_edns_option_list *options_list)
size_t ldns_edns_get_size(const ldns_edns_option *edns)
returns the size of the EDNS data.
size_t ldns_edns_option_list_get_count(const ldns_edns_option_list *options_list)
returns the number of options in the EDNS options list.
@ LDNS_EDNS_CLIENT_SUBNET
@ LDNS_STATUS_WIRE_RDATA_ERR
@ LDNS_STATUS_NO_SVCPARAM_VALUE_EXPECTED
@ LDNS_STATUS_INVALID_SVCPARAM_VALUE
@ LDNS_STATUS_DOMAINNAME_OVERFLOW
@ LDNS_STATUS_RDATA_OVERFLOW
enum ldns_enum_status ldns_status
ldns_status ldns_rr2buffer_str(ldns_buffer *output, const ldns_rr *rr)
Converts the data in the resource record to presentation format (as char *) and appends it to the giv...
ldns_status ldns_rdf2buffer_str_hip(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_HIP rdata element to presentation format for the algorithm,...
ldns_status ldns_rdf2buffer_str_wks(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_WKS rdata element to string format and adds it to the output buffer.
const ldns_output_format * ldns_output_format_nocomments
Standard output format record that disables commenting in the textual representation of Resource Reco...
char * ldns_rr_class2str(const ldns_rr_class klass)
Converts an ldns_rr_class value to its string representation, and returns that string.
ldns_edns_option_list * pkt_edns_data2edns_option_list(const ldns_rdf *edns_data)
char * ldns_rr2str_fmt(const ldns_output_format *fmt, const ldns_rr *rr)
Converts the data in the resource record to presentation format and returns that as a char *.
char * ldns_key2str(const ldns_key *k)
Converts a private key to the test presentation fmt and returns that as a char *.
ldns_status ldns_key2buffer_str(ldns_buffer *output, const ldns_key *k)
Converts the data in the DNS packet to presentation format (as char *) and appends it to the given bu...
ldns_status ldns_rdf2buffer_str_int32(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_INT32 rdata element to string format and adds it to the output buffer.
ldns_status ldns_edns_option_list2buffer_str(ldns_buffer *output, ldns_edns_option_list *edns_list)
Converts the list of EDNS options to presentation format (as char *) and appends it to the given buff...
char * ldns_pkt2str_fmt(const ldns_output_format *fmt, const ldns_pkt *pkt)
Converts the data in the DNS packet to presentation format and returns that as a char *.
ldns_status ldns_rdf2buffer_str_hex(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_HEX rdata element to string format and adds it to the output buffer.
char * ldns_pkt_rcode2str(ldns_pkt_rcode rcode)
Converts a packet rcode to its mnemonic and returns that as an allocated null-terminated string.
ldns_status ldns_rdf2buffer_str_str(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_STR rdata element to string format and adds it to the output buffer.
ldns_status ldns_pkt_rcode2buffer_str(ldns_buffer *output, ldns_pkt_rcode rcode)
Converts an ldns packet rcode value to its mnemonic, and adds that to the output buffer.
ldns_status ldns_rdf2buffer_str_loc(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_LOC rdata element to string format and adds it to the output buffer.
ldns_status ldns_rdf2buffer_str_apl(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_APL rdata element to string format and adds it to the output buffer.
char * ldns_rr_type2str(const ldns_rr_type type)
Converts an ldns_rr_type value to its string representation, and returns that string.
ldns_status ldns_rdf2buffer_str_nsap(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_NSAP rdata element to string format and adds it to the output buffer.
void ldns_rr_list_print_fmt(FILE *output, const ldns_output_format *fmt, const ldns_rr_list *lst)
print a rr_list to output
ldns_lookup_table ldns_rcodes[]
Response codes.
ldns_status ldns_rdf2buffer_str_b64(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_B64 rdata element to string format and adds it to the output buffer.
ldns_status ldns_rdf2buffer_str_type(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_TYPE rdata element to string format and adds it to the output buffer.
ldns_status ldns_rdf2buffer_str(ldns_buffer *buffer, const ldns_rdf *rdf)
Converts the data in the rdata field to presentation format (as char *) and appends it to the given b...
void ldns_pkt_print_fmt(FILE *output, const ldns_output_format *fmt, const ldns_pkt *pkt)
Prints the data in the DNS packet to the given file stream (in presentation format)
char * ldns_pkt_algorithm2str(ldns_algorithm algorithm)
Converts a signing algorithms to its mnemonic and returns that as an allocated null-terminated string...
ldns_status ldns_pkt2buffer_str_fmt(ldns_buffer *output, const ldns_output_format *fmt, const ldns_pkt *pkt)
Converts the data in the DNS packet to presentation format (as char *) and appends it to the given bu...
char * ldns_rr_list2str(const ldns_rr_list *list)
Converts a list of resource records to presentation format and returns that as a char *.
ldns_status ldns_rr2buffer_str_fmt(ldns_buffer *output, const ldns_output_format *fmt, const ldns_rr *rr)
Converts the data in the resource record to presentation format (as char *) and appends it to the giv...
const ldns_output_format ldns_output_format_nocomments_record
void ldns_zone_print_fmt(FILE *output, const ldns_output_format *fmt, const ldns_zone *z)
Print a zone structure * to output.
ldns_status ldns_pktheader2buffer_str(ldns_buffer *output, const ldns_pkt *pkt)
Converts the header of a packet to presentation format and appends it to the output buffer.
const ldns_output_format * ldns_output_format_onlykeyids
Standard output format record that annotated only DNSKEY RR's with comment text.
ldns_status ldns_rdf2buffer_str_tag(ldns_buffer *output, const ldns_rdf *rdf)
Adds the LDNS_RDF_TYPE_TAG rdata to the output buffer, provided it contains only alphanumeric charact...
const ldns_output_format ldns_output_format_onlykeyids_record
ldns_status ldns_rr_list2buffer_str(ldns_buffer *output, const ldns_rr_list *list)
Converts a rr_list to presentation format and appends it to the output buffer.
ldns_status ldns_rr_class2buffer_str(ldns_buffer *output, const ldns_rr_class klass)
Converts an ldns_rr_class value to its string representation, and places it in the given buffer.
char * ldns_pkt_cert_algorithm2str(ldns_cert_algorithm cert_algorithm)
Converts a cert algorithm to its mnemonic and returns that as an allocated null-terminated string.
void ldns_rdf_print(FILE *output, const ldns_rdf *rdf)
Prints the data in the rdata field to the given file stream (in presentation format)
ldns_lookup_table ldns_algorithms[]
Taken from RFC 2535, section 7.
ldns_status ldns_algorithm2buffer_str(ldns_buffer *output, ldns_algorithm algorithm)
Converts an ldns algorithm type to its mnemonic, and adds that to the output buffer.
ldns_status ldns_rdf2buffer_str_time(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_TIME rdata element to string format and adds it to the output buffer.
void ldns_rr_print(FILE *output, const ldns_rr *rr)
Prints the data in the resource record to the given file stream (in presentation format)
char * ldns_buffer_export2str(ldns_buffer *buffer)
Exports and returns the data in the buffer as a null terminated char * string.
ldns_status svcparam_key2buffer_str(ldns_buffer *output, uint16_t key)
ldns_status ldns_cert_algorithm2buffer_str(ldns_buffer *output, ldns_cert_algorithm cert_algorithm)
Converts an ldns certificate algorithm type to its mnemonic, and adds that to the output buffer.
char * ldns_buffer2str(ldns_buffer *buffer)
Returns a copy of the data in the buffer as a null terminated char * string.
char * ldns_pkt2str(const ldns_pkt *pkt)
Converts the data in the DNS packet to presentation format and returns that as a char *.
void ldns_resolver_print_fmt(FILE *output, const ldns_output_format *fmt, const ldns_resolver *r)
Print a resolver (in sofar that is possible) state to output.
char * ldns_pkt_opcode2str(ldns_pkt_opcode opcode)
Converts a packet opcode to its mnemonic and returns that as an allocated null-terminated string.
ldns_lookup_table ldns_opcodes[]
Operation codes.
ldns_status ldns_rdf2buffer_str_tsigtime(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_TSIGTIME rdata element to string format and adds it to the output buffer.
ldns_status ldns_rdf2buffer_str_eui48(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_EUI48 rdata element to 6 hexadecimal numbers separated by dashes and adds i...
ldns_status ldns_rdf2buffer_str_int8(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_INT8 rdata element to string format and adds it to the output buffer.
ldns_status ldns_rdf2buffer_str_alg(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_ALG rdata element to string format and adds it to the output buffer.
ldns_status ldns_rdf2buffer_str_svcparams(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_SVCPARAMS rdata element to presentation format.
char * ldns_rr2str(const ldns_rr *rr)
Converts the data in the resource record to presentation format and returns that as a char *.
ldns_status ldns_rdf2buffer_str_eui64(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_EUI64 rdata element to 8 hexadecimal numbers separated by dashes and adds i...
ldns_status ldns_rdf2buffer_str_amtrelay(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_AMTRELAY rdata element to presentation format for the precedence,...
ldns_status ldns_rdf2buffer_str_ilnp64(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_ILNP64 rdata element to 4 hexadecimal numbers separated by colons and adds ...
ldns_status ldns_rdf2buffer_str_nsec(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_NSEC rdata element to string format and adds it to the output buffer.
void ldns_resolver_print(FILE *output, const ldns_resolver *r)
Print a resolver (in sofar that is possible) state to output.
ldns_status ldns_rdf2buffer_str_long_str(ldns_buffer *output, const ldns_rdf *rdf)
Adds the LDNS_RDF_TYPE_LONG_STR rdata to the output buffer, in-between double quotes and all non prin...
ldns_status ldns_output_format_clear_type(ldns_output_format *fmt, ldns_rr_type t)
Makes sure the LDNS_FMT_RFC3597 is set in the output format.
ldns_status ldns_rdf2buffer_str_b32_ext(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_B32_EXT rdata element to string format and adds it to the output buffer.
ldns_status ldns_rdf2buffer_str_unknown(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_UNKNOWN rdata element to string format and adds it to the output buffer.
void ldns_zone_print(FILE *output, const ldns_zone *z)
Print a zone structure * to output.
ldns_status ldns_rdf2buffer_str_cert_alg(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_CERT rdata element to string format and adds it to the output buffer.
void ldns_rr_list_print(FILE *output, const ldns_rr_list *lst)
print a rr_list to output
ldns_status ldns_rdf2buffer_str_class(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_CLASS rdata element to string format and adds it to the output buffer.
ldns_lookup_table ldns_rr_classes[]
rr types
ldns_status ldns_rdf2buffer_str_int16(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_INT16 rdata element to string format and adds it to the output buffer.
ldns_status ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_IPSECKEY rdata element to string format and adds it to the output buffer.
ldns_status ldns_pkt_opcode2buffer_str(ldns_buffer *output, ldns_pkt_opcode opcode)
Converts an ldns packet opcode value to its mnemonic, and adds that to the output buffer.
const ldns_output_format * ldns_output_format_default
The default output format record.
ldns_status ldns_rdf2buffer_str_period(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_PERIOD rdata element to string format and adds it to the output buffer.
void ldns_pkt_print(FILE *output, const ldns_pkt *pkt)
Prints the data in the DNS packet to the given file stream (in presentation format)
ldns_status ldns_rr_list2buffer_str_fmt(ldns_buffer *output, const ldns_output_format *fmt, const ldns_rr_list *list)
Converts a rr_list to presentation format and appends it to the output buffer.
ldns_status ldns_rdf2buffer_str_dname(ldns_buffer *output, const ldns_rdf *dname)
Print the ldns_rdf containing a dname to the buffer.
ldns_lookup_table ldns_hashes[]
ldns_lookup_table ldns_cert_algorithms[]
Taken from RFC 2538.
ldns_status ldns_rdf2buffer_str_a(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_A rdata element to string format and adds it to the output buffer.
ldns_status ldns_output_format_set_type(ldns_output_format *fmt, ldns_rr_type t)
Makes sure the LDNS_FMT_RFC3597 is set in the output format.
char * ldns_rdf2str(const ldns_rdf *rdf)
Converts the data in the rdata field to presentation format and returns that as a char *.
ldns_status ldns_rdf2buffer_str_nsec3_salt(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_NSEC3_SALT rdata element to string format and adds it to the output buffer.
const ldns_output_format ldns_output_format_bubblebabble_record
const ldns_output_format * ldns_output_format_bubblebabble
Standard output format record that shows all DNSKEY related information in the comment text,...
ldns_status ldns_rr_type2buffer_str(ldns_buffer *output, const ldns_rr_type type)
Converts an ldns_rr_type value to its string representation, and places it in the given buffer.
ldns_status ldns_pkt2buffer_str(ldns_buffer *output, const ldns_pkt *pkt)
Converts the data in the DNS packet to presentation format (as char *) and appends it to the given bu...
char * ldns_rr_list2str_fmt(const ldns_output_format *fmt, const ldns_rr_list *list)
Converts a list of resource records to presentation format and returns that as a char *.
ldns_status ldns_rdf2buffer_str_int16_data(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_INT16_DATA rdata element to string format and adds it to the output buffer.
ldns_status ldns_rdf2buffer_str_aaaa(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_AAAA rdata element to string format and adds it to the output buffer.
ldns_status ldns_rdf2buffer_str_atma(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_ATMA rdata element to string format and adds it to the output buffer.
void ldns_rr_print_fmt(FILE *output, const ldns_output_format *fmt, const ldns_rr *rr)
Prints the data in the resource record to the given file stream (in presentation format)
#define LDNS_COMMENT_KEY_SIZE
Show DNSKEY key size as comment.
#define LDNS_COMMENT_RRSIGS
Also comment KEY_ID with RRSIGS.
#define LDNS_FMT_PAD_SOA_SERIAL
#define LDNS_COMMENT_BUBBLEBABBLE
Provide bubblebabble representation for DS RR's as comment.
#define LDNS_FMT_ZEROIZE_RRSIGS
#define LDNS_COMMENT_FLAGS
Show when a NSEC3 RR has the optout flag set as comment.
#define LDNS_COMMENT_NULLS
Represent a NULL pointer (instead of a pointer to a ldns_rr as "; (null)" as opposed to outputting no...
#define LDNS_COMMENT_KEY_ID
Show key id with DNSKEY RR's as comment.
#define LDNS_APL_NEGATION
#define LDNS_FMT_SHORT
Prints only answer section of packets and only rdata of RRs.
#define LDNS_COMMENT_KEY_TYPE
Show if a DNSKEY is a ZSK or KSK as comment.
#define LDNS_COMMENT_KEY
Show key id, type and size as comment for DNSKEY RR's.
#define LDNS_COMMENT_NSEC3_CHAIN
Show the unhashed owner and next owner names for NSEC3 RR's as comment.
unsigned char * ldns_key_hmac_key(const ldns_key *k)
return the hmac key data
size_t ldns_key_hmac_size(const ldns_key *k)
return the hmac key size
ldns_signing_algorithm ldns_key_algorithm(const ldns_key *k)
return the signing alg of the key
@ LDNS_SIGN_ECDSAP256SHA256
@ LDNS_SIGN_RSASHA1_NSEC3
@ LDNS_SIGN_ECDSAP384SHA384
RSA * ldns_key_rsa_key(const ldns_key *k)
returns the (openssl) RSA struct contained in the key
#define LDNS_KEY_ZONE_KEY
DSA * ldns_key_dsa_key(const ldns_key *k)
returns the (openssl) DSA struct contained in the key
enum ldns_enum_algorithm ldns_algorithm
Including this file will include all ldns files, and define some lookup tables.
#define LDNS_MAX_PACKETLEN
signed char ldns_pkt_edns(const ldns_pkt *packet)
returns true if this packet needs and EDNS rr to be sent.
uint8_t ldns_pkt_edns_version(const ldns_pkt *packet)
return the packet's edns version
signed char ldns_pkt_aa(const ldns_pkt *p)
Read the packet's aa bit.
size_t ldns_pkt_size(const ldns_pkt *p)
Return the packet's size in bytes.
ldns_rr * ldns_pkt_tsig(const ldns_pkt *p)
Return the packet's tsig pseudo rr's.
ldns_rr_list * ldns_pkt_question(const ldns_pkt *p)
Return the packet's question section.
ldns_rr_list * ldns_pkt_authority(const ldns_pkt *p)
Return the packet's authority section.
uint32_t ldns_pkt_querytime(const ldns_pkt *p)
Return the packet's querytime.
uint16_t ldns_pkt_ancount(const ldns_pkt *p)
Return the packet's an count.
uint16_t ldns_pkt_nscount(const ldns_pkt *p)
Return the packet's ns count.
ldns_rdf * ldns_pkt_answerfrom(const ldns_pkt *p)
Return the packet's answerfrom.
ldns_rr_list * ldns_pkt_answer(const ldns_pkt *p)
Return the packet's answer section.
enum ldns_enum_pkt_rcode ldns_pkt_rcode
uint16_t ldns_pkt_id(const ldns_pkt *p)
Read the packet id.
signed char ldns_pkt_tc(const ldns_pkt *p)
Read the packet's tc bit.
signed char ldns_pkt_ra(const ldns_pkt *p)
Read the packet's ra bit.
enum ldns_enum_pkt_opcode ldns_pkt_opcode
uint8_t ldns_pkt_edns_extended_rcode(const ldns_pkt *packet)
return the packet's edns extended rcode
uint16_t ldns_pkt_qdcount(const ldns_pkt *p)
Return the packet's qd count.
signed char ldns_pkt_cd(const ldns_pkt *p)
Read the packet's cd bit.
ldns_rr_list * ldns_pkt_additional(const ldns_pkt *p)
Return the packet's additional section.
ldns_pkt_opcode ldns_pkt_get_opcode(const ldns_pkt *p)
Read the packet's code.
signed char ldns_pkt_edns_do(const ldns_pkt *packet)
return the packet's edns do bit
uint16_t ldns_pkt_arcount(const ldns_pkt *p)
Return the packet's ar count.
ldns_rdf * ldns_pkt_edns_data(const ldns_pkt *packet)
return the packet's EDNS data
signed char ldns_pkt_qr(const ldns_pkt *p)
Read the packet's qr bit.
struct timeval ldns_pkt_timestamp(const ldns_pkt *p)
Return the packet's timestamp.
signed char ldns_pkt_rd(const ldns_pkt *p)
Read the packet's rd bit.
signed char ldns_pkt_ad(const ldns_pkt *p)
Read the packet's ad bit.
ldns_pkt_rcode ldns_pkt_get_rcode(const ldns_pkt *p)
Return the packet's response code.
uint16_t ldns_pkt_edns_udp_size(const ldns_pkt *packet)
return the packet's edns udp size
ldns_rbnode_t * ldns_rbtree_search(ldns_rbtree_t *rbtree, const void *key)
Find key in tree.
enum ldns_enum_cert_algorithm ldns_cert_algorithm
ldns_rdf_type ldns_rdf_get_type(const ldns_rdf *rd)
returns the type of the rdf.
void ldns_rdf_deep_free(ldns_rdf *rd)
frees a rdf structure and frees the data.
ldns_rdf * ldns_rdf_new(ldns_rdf_type type, size_t size, void *data)
allocates a new rdf structure and fills it.
uint32_t ldns_rdf2native_int32(const ldns_rdf *rd)
returns the native uint32_t representation from the rdf.
uint16_t ldns_rdf2native_int16(const ldns_rdf *rd)
returns the native uint16_t representation from the rdf.
enum ldns_enum_svcparam_key ldns_svcparam_key
@ LDNS_RDF_TYPE_INT32
32 bits
@ LDNS_RDF_TYPE_TAG
A non-zero sequence of US-ASCII letters and numbers in lower case.
@ LDNS_RDF_TYPE_NSAP
NSAP.
@ LDNS_RDF_TYPE_HIP
Represents the Public Key Algorithm, HIT and Public Key fields for the HIP RR types.
@ LDNS_RDF_TYPE_B32_EXT
b32 string
@ LDNS_RDF_TYPE_NSEC3_NEXT_OWNER
nsec3 base32 string (with length byte on wire
@ LDNS_RDF_TYPE_CERT_ALG
certificate algorithm
@ LDNS_RDF_TYPE_EUI48
6 * 8 bit hex numbers separated by dashes.
@ LDNS_RDF_TYPE_SERVICE
protocol and port bitmaps
@ LDNS_RDF_TYPE_EUI64
8 * 8 bit hex numbers separated by dashes.
@ LDNS_RDF_TYPE_PERIOD
period
@ LDNS_RDF_TYPE_B64
b64 string
@ LDNS_RDF_TYPE_AAAA
AAAA record.
@ LDNS_RDF_TYPE_UNKNOWN
unknown types
@ LDNS_RDF_TYPE_WKS
well known services
@ LDNS_RDF_TYPE_DNAME
domain name
@ LDNS_RDF_TYPE_TIME
time (32 bits)
@ LDNS_RDF_TYPE_SVCPARAMS
draft-ietf-dnsop-svcb-https
@ LDNS_RDF_TYPE_NSEC
nsec type codes
@ LDNS_RDF_TYPE_NSEC3_SALT
nsec3 hash salt
@ LDNS_RDF_TYPE_APL
apl data
@ LDNS_RDF_TYPE_A
A record.
@ LDNS_RDF_TYPE_LONG_STR
A <character-string> encoding of the value field as specified [RFC1035], Section 5....
@ LDNS_RDF_TYPE_LOC
location data
@ LDNS_RDF_TYPE_INT16_DATA
variable length any type rdata where the length is specified by the first 2 bytes
@ LDNS_RDF_TYPE_ILNP64
4 shorts represented as 4 * 16 bit hex numbers separated by colons.
@ LDNS_RDF_TYPE_ATMA
ATMA.
@ LDNS_RDF_TYPE_HEX
hex string
@ LDNS_RDF_TYPE_CLASS
a class
@ LDNS_RDF_TYPE_INT8
8 bits
@ LDNS_RDF_TYPE_MATCHING_TYPE
@ LDNS_RDF_TYPE_IPSECKEY
IPSECKEY.
@ LDNS_RDF_TYPE_CERTIFICATE_USAGE
Since RFC7218 TLSA records can be given with mnemonics, hence these rdata field types.
@ LDNS_RDF_TYPE_STR
txt string
@ LDNS_RDF_TYPE_INT16
16 bits
@ LDNS_RDF_TYPE_ALG
a key algorithm
@ LDNS_RDF_TYPE_AMTRELAY
draft-ietf-mboned-driad-amt-discovery
@ LDNS_RDF_TYPE_TSIGTIME
tsig time 48 bits
@ LDNS_RDF_TYPE_TYPE
a RR type
size_t ldns_rdf_size(const ldns_rdf *rd)
returns the size of the rdf.
uint8_t * ldns_rdf_data(const ldns_rdf *rd)
returns the data of the rdf.
@ LDNS_SVCPARAM_KEY_MANDATORY
@ LDNS_SVCPARAM_KEY_IPV4HINT
@ LDNS_SVCPARAM_KEY_IPV6HINT
@ LDNS_SVCPARAM_KEY_NO_DEFAULT_ALPN
ldns_rdf * ldns_rdf_new_frm_data(ldns_rdf_type type, size_t size, const void *data)
allocates a new rdf structure and fills it.
const char * ldns_resolver_tsig_algorithm(const ldns_resolver *r)
Return the tsig algorithm as used by the nameserver.
#define LDNS_RESOLV_RTT_MIN
signed char ldns_resolver_dnssec_cd(const ldns_resolver *r)
Does the resolver set the CD bit.
signed char ldns_resolver_fail(const ldns_resolver *r)
Does the resolver only try the first nameserver.
#define LDNS_RESOLV_RTT_INF
signed char ldns_resolver_recursive(const ldns_resolver *r)
Is the resolver set to recurse.
size_t ldns_resolver_searchlist_count(const ldns_resolver *r)
Return the resolver's searchlist count.
ldns_rr_list * ldns_resolver_dnssec_anchors(const ldns_resolver *r)
Get the resolver's DNSSEC anchors.
signed char ldns_resolver_dnsrch(const ldns_resolver *r)
Does the resolver apply search list.
signed char ldns_resolver_fallback(const ldns_resolver *r)
Get the truncation fallback status.
size_t ldns_resolver_nameserver_count(const ldns_resolver *r)
How many nameserver are configured in the resolver.
uint8_t ldns_resolver_retrans(const ldns_resolver *r)
Get the retransmit interval.
signed char ldns_resolver_defnames(const ldns_resolver *r)
Does the resolver apply default domain name.
ldns_rdf * ldns_resolver_domain(const ldns_resolver *r)
What is the default dname to add to relative queries.
uint16_t ldns_resolver_edns_udp_size(const ldns_resolver *r)
Get the resolver's udp size.
signed char ldns_resolver_dnssec(const ldns_resolver *r)
Does the resolver do DNSSEC.
struct timeval ldns_resolver_timeout(const ldns_resolver *r)
What is the timeout on socket connections.
size_t * ldns_resolver_rtt(const ldns_resolver *r)
Return the used round trip times for the nameservers.
uint8_t ldns_resolver_ip6(const ldns_resolver *r)
Does the resolver use ip6 or ip4.
signed char ldns_resolver_random(const ldns_resolver *r)
Does the resolver randomize the nameserver before usage.
uint8_t ldns_resolver_retry(const ldns_resolver *r)
Get the number of retries.
ldns_rdf ** ldns_resolver_searchlist(const ldns_resolver *r)
What is the searchlist as used by the resolver.
const char * ldns_resolver_tsig_keyname(const ldns_resolver *r)
Return the tsig keyname as used by the nameserver.
ldns_rdf ** ldns_resolver_nameservers(const ldns_resolver *r)
Return the configured nameserver ip address.
signed char ldns_resolver_usevc(const ldns_resolver *r)
Does the resolver use tcp or udp.
signed char ldns_resolver_igntc(const ldns_resolver *r)
Does the resolver ignore the TC bit (truncated)
uint16_t ldns_resolver_port(const ldns_resolver *r)
Get the port the resolver should use.
signed char ldns_resolver_debug(const ldns_resolver *r)
Get the debug status of the resolver.
ldns_rr * ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr)
returns a specific rr of an rrlist.
uint32_t ldns_rr_ttl(const ldns_rr *rr)
returns the ttl of an rr structure.
ldns_rdf * ldns_rr_owner(const ldns_rr *rr)
returns the owner name of an rr structure.
const ldns_rr_descriptor * ldns_rr_descript(uint16_t type)
returns the resource record descriptor for the given rr type.
enum ldns_enum_rr_type ldns_rr_type
@ LDNS_RR_TYPE_RRSIG
DNSSEC.
@ LDNS_RR_TYPE_SOA
marks the start of a zone of authority
@ LDNS_RR_TYPE_DS
RFC4034, RFC3658.
@ LDNS_RR_TYPE_MAILA
A request for mail agent RRs (Obsolete - see MX)
@ LDNS_RR_TYPE_ANY
any type (wildcard)
@ LDNS_RR_TYPE_MAILB
A request for mailbox-related records (MB, MG or MR)
signed char ldns_rr_is_question(const ldns_rr *rr)
returns the question flag of an rr structure.
size_t ldns_rr_rd_count(const ldns_rr *rr)
returns the rd_count of an rr structure.
size_t ldns_rr_list_rr_count(const ldns_rr_list *rr_list)
returns the number of rr's in an rr_list.
ldns_rr_type ldns_rr_get_type(const ldns_rr *rr)
returns the type of the rr.
ldns_rr_class ldns_rr_get_class(const ldns_rr *rr)
returns the class of the rr.
enum ldns_enum_rr_class ldns_rr_class
ldns_status ldns_rdf_bitmap_known_rr_types_space(ldns_rdf **rdf)
Create a rr type bitmap rdf providing enough space to set all known (to ldns) rr types.
#define LDNS_MAX_DOMAINLEN
Maximum length of a complete dname.
@ LDNS_RR_CLASS_NONE
None class, dynamic update.
@ LDNS_RR_CLASS_IN
the Internet
@ LDNS_RR_CLASS_CH
Chaos class.
@ LDNS_RR_CLASS_HS
Hesiod (Dyer 87)
@ LDNS_RR_CLASS_ANY
Any class.
ldns_rdf * ldns_rr_rdf(const ldns_rr *rr, size_t nr)
returns the rdata field member counter.
ldns_status ldns_rdf_bitmap_known_rr_types(ldns_rdf **rdf)
Create a rr type bitmap rdf with at least all known (to ldns) rr types set.
size_t ldns_rr_dnskey_key_size(const ldns_rr *key)
get the length of the keydata in bits
ldns_status ldns_str2rdf_dname(ldns_rdf **rd, const char *str)
convert a dname string into wireformat
The rbnode_t struct definition.
const void * data
pointer to data
implementation of buffers to ease operations
size_t _position
The current position used for reading/writing.
The struct that stores an ordered EDNS option.
General key structure, can contain all types of keys that are used in DNSSEC.
struct ldns_struct_key::@0 _key
Storage pointers for the types of keys supported.
A general purpose lookup table.
ldns_edns_option_list * _edns_list
Structed EDNS data.
Resource record data field.
DNS stub resolver structure.
Contains all information about resource record types.
const char * _name
Textual name of the RR type.
List or Set of Resource Records.
int ldns_b32_ntop_extended_hex(const uint8_t *src_data, size_t src_data_length, char *target_text_buffer, size_t target_text_buffer_size)
ldns_lookup_table * ldns_lookup_by_id(ldns_lookup_table table[], int id)
Looks up the table entry by id, returns NULL if not found.
#define LDNS_XMALLOC(type, count)
int ldns_get_bit(uint8_t bits[], size_t index)
Returns the value of the specified bit The bits are counted from left to right, so bit #0 is the left...
char * ldns_bubblebabble(uint8_t *data, size_t len)
Encode data as BubbleBabble.
struct tm * ldns_serial_arithmetics_gmtime_r(int32_t time, time_t now, struct tm *result)
The function interprets time as the number of seconds since epoch with respect to now using serial ar...
ldns_status ldns_wire2dname(ldns_rdf **dname, const uint8_t *wire, size_t max, size_t *pos)
converts the data on the uint8_t bytearray (in wire format) to a DNS dname rdata field.
ldns_rr_list * ldns_zone_rrs(const ldns_zone *z)
Get a list of a zone's content.
ldns_rr * ldns_zone_soa(const ldns_zone *z)
Return the soa record of a zone.