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 #ifdef HAVE_ENDPROTOENT
842 for (current_service = 0;
843 current_service < (
ldns_rdf_size(rdf)-1)*8; current_service++) {
845 service = getservbyport((
int) htons(current_service),
847 if (service && service->s_name) {
852 #ifdef HAVE_ENDSERVENT
857 if(current_service == 65535) {
break; }
859 return ldns_buffer_status(output);
869 uint8_t window_block_nr;
870 uint8_t bitmap_length;
877 window_block_nr = data[pos];
878 bitmap_length = data[pos + 1];
883 for (bit_pos = 0; bit_pos < (bitmap_length) * 8; bit_pos++) {
887 type = 256 * (uint16_t) window_block_nr + bit_pos;
889 if (! ldns_output_format_covers_type(fmt, type) &&
899 pos += (uint16_t) bitmap_length;
901 return ldns_buffer_status(output);
907 return ldns_rdf2buffer_str_nsec_fmt(output,
922 salt_length = data[0];
924 if (salt_length == 0 || ((
size_t)salt_length)+1 >
ldns_rdf_size(rdf)) {
927 for (salt_pos = 0; salt_pos < salt_length; salt_pos++) {
933 return ldns_buffer_status(output);
944 return ldns_buffer_status(output);
951 uint64_t tsigtime = 0;
953 uint64_t d0, d1, d2, d3, d4, d5;
964 tsigtime = (d0<<40) | (d1<<32) | (d2<<24) | (d3<<16) | (d4<<8) | d5;
968 return ldns_buffer_status(output);
975 uint16_t address_family;
985 address_family = ldns_read_uint16(&data[pos]);
986 prefix = data[pos + 2];
996 for (i = 0; i < 4; i++) {
1000 if (i < (
unsigned short) adf_length) {
1017 for (i = 0; i < 16; i++) {
1018 if (i % 2 == 0 && i > 0) {
1021 if (i < (
unsigned short) adf_length) {
1035 "Unknown address family: %u data: ",
1037 for (i = 1; i < (
unsigned short) (4 + adf_length); i++) {
1043 pos += 4 + adf_length;
1045 return ldns_buffer_status(output);
1057 size = ldns_b64_ntop_calculate_size(
ldns_rdf_size(rdf) - 2);
1072 return ldns_buffer_status(output);
1083 uint8_t gateway_type;
1087 uint8_t *gateway_data;
1089 size_t public_key_size;
1090 uint8_t *public_key_data;
1099 precedence = data[0];
1100 gateway_type = data[1];
1101 algorithm = data[2];
1104 switch (gateway_type) {
1157 public_key_data =
LDNS_XMALLOC(uint8_t, public_key_size);
1158 if(!public_key_data) {
1162 memcpy(public_key_data, &data[offset], public_key_size);
1164 public_key_size, public_key_data);
1182 return ldns_buffer_status(output);
1196 return ldns_buffer_status(output);
1209 return ldns_buffer_status(output);
1223 return ldns_buffer_status(output);
1230 const uint8_t* chars;
1241 while (nchars > 0) {
1242 ch = (char)*chars++;
1243 if (! isalnum((
unsigned char)ch)) {
1249 return ldns_buffer_status(output);
1257 ldns_characters2buffer_str(output,
1260 return ldns_buffer_status(output);
1275 if ((hit_size = data[0]) == 0 ||
1276 (pk_size = ldns_read_uint16(data + 2)) == 0 ||
1277 rdf_size < (
size_t) hit_size + pk_size + 4) {
1284 for (data += 4; hit_size > 0; hit_size--, data++) {
1288 ldns_buffer_write_char(output, (uint8_t)
' ');
1291 ldns_b64_ntop_calculate_size(pk_size))) {
1294 (
char *) ldns_buffer_current(output),
1295 ldns_buffer_remaining(output));
1298 written < (
int) ldns_buffer_remaining(output)) {
1303 return ldns_buffer_status(output);
1315 uint8_t discovery_optional;
1319 uint8_t *relay_data;
1327 precedence = data[0];
1328 discovery_optional = ((data[1] & 0x80) >> 7);
1329 relay_type = data[1] & 0x7F;
1332 switch (relay_type) {
1385 precedence, discovery_optional, relay_type);
1390 return ldns_buffer_status(output);
1393 #ifdef RRTYPE_SVCB_HTTPS
1397 svcparam_mandatory2buffer_str(
ldns_buffer *output,
size_t sz, uint8_t *data)
1403 for (data += 2, sz -= 2; sz; data += 2, sz -= 2) {
1404 ldns_buffer_write_char(output,
',');
1407 return ldns_buffer_status(output);
1411 svcparam_alpn2buffer_str(
ldns_buffer *output,
size_t sz, uint8_t *data)
1413 uint8_t *eod = data + sz, *dp;
1417 for (dp = data; dp < eod && !quote; dp += 1 + *dp) {
1418 if (dp + 1 + *dp > eod)
1421 for (i = 0; i < *dp; i++)
1422 if (isspace(dp[i + 1]))
1427 ldns_buffer_write_char(output,
'"');
1428 while (data < eod) {
1429 uint8_t *eot = data + 1 + *data;
1434 if (eod - data < (
int)sz)
1435 ldns_buffer_write_char(output,
',');
1437 for (data += 1; data < eot; data += 1) {
1440 if (isprint(ch) || ch ==
'\t') {
1441 if (ch ==
'"' || ch ==
',' || ch ==
'\\')
1442 ldns_buffer_write_char(output,
'\\');
1443 ldns_buffer_write_char(output, ch);
1450 ldns_buffer_write_char(output,
'"');
1451 return ldns_buffer_status(output);
1455 svcparam_port2buffer_str(
ldns_buffer *output,
size_t sz, uint8_t *data)
1460 return ldns_buffer_status(output);
1464 svcparam_ipv4hint2buffer_str(
ldns_buffer *output,
size_t sz, uint8_t *data)
1471 ldns_buffer_write_chars(output, str);
1473 for (data += 4, sz -= 4; sz ; data += 4, sz -= 4 ) {
1474 ldns_buffer_write_char(output,
',');
1478 ldns_buffer_write_chars(output, str);
1480 return ldns_buffer_status(output);
1484 svcparam_ech2buffer_str(
ldns_buffer *output,
size_t sz, uint8_t *data)
1486 size_t str_sz = ldns_b64_ntop_calculate_size(sz);
1493 , (
char *)ldns_buffer_current(output), str_sz);
1495 ldns_buffer_skip(output, written);
1499 return ldns_buffer_status(output);
1503 svcparam_ipv6hint2buffer_str(
ldns_buffer *output,
size_t sz, uint8_t *data)
1510 ldns_buffer_write_chars(output, str);
1512 for (data += 16, sz -= 16; sz ; data += 16, sz -= 16) {
1513 ldns_buffer_write_char(output,
',');
1517 ldns_buffer_write_chars(output, str);
1519 return ldns_buffer_status(output);
1523 svcparam_value2buffer_str(
ldns_buffer *output,
size_t sz, uint8_t *data)
1525 uint8_t *eod = data + sz, *dp;
1528 for (dp = data; dp < eod && !isspace(*dp); dp++)
1531 if ((quote = dp < eod))
1532 ldns_buffer_write_char(output,
'"');
1534 for (dp = data; dp < eod; dp++) {
1537 if (isprint(ch) || ch ==
'\t') {
1538 if (ch ==
'"' || ch ==
'\\')
1539 ldns_buffer_write_char(output,
'\\');
1540 ldns_buffer_write_char(output, ch);
1545 ldns_buffer_write_char(output,
'"');
1546 return ldns_buffer_status(output);
1552 uint8_t *data, *dp, *next_dp = NULL;
1563 for (dp = data; dp + 4 <= data + sz; dp = next_dp) {
1565 uint16_t val_sz = ldns_read_uint16(dp + 2);
1567 if ((next_dp = dp + 4 + val_sz) > data + sz)
1571 ldns_buffer_write_char(output,
' ');
1579 ldns_buffer_write_char(output,
'=');
1582 st = svcparam_mandatory2buffer_str(output, val_sz, dp);
1585 st = svcparam_alpn2buffer_str(output, val_sz, dp);
1590 st = svcparam_port2buffer_str(output, val_sz, dp);
1593 st = svcparam_ipv4hint2buffer_str(output, val_sz, dp);
1596 st = svcparam_ech2buffer_str(output, val_sz, dp);
1599 st = svcparam_ipv6hint2buffer_str(output, val_sz, dp);
1602 st = svcparam_value2buffer_str(output, val_sz, dp);
1608 return ldns_buffer_status(output);
1614 (void)output; (void)rdf;
1674 res = ldns_rdf2buffer_str_nsec_fmt(buffer, fmt, rdf);
1680 res = ldns_rdf2buffer_str_type_fmt(buffer, fmt, rdf);
1756 ldns_b32_ext2dname(
const ldns_rdf *rdf)
1764 size = ldns_b32_ntop_calculate_size(
ldns_rdf_size(rdf) - 1);
1785 size_t total_rdfsize = 0;
1792 if (total_rdfsize == 0) {
1794 return ldns_buffer_status(output);
1804 return ldns_buffer_status(output);
1815 if (fmt_st == NULL) {
1824 return ldns_buffer_status(output);
1846 return ldns_rr2buffer_str_rfc3597(output, rr);
1878 status = ldns_buffer_status(output);
1885 (
unsigned long) ldns_read_uint32(
1887 status = ldns_buffer_status(output);
1889 status = ldns_rdf2buffer_str_fmt(output,
1926 }
else if (fmt_st->
flags
2000 key = ldns_b32_ext2dname(
2028 return ldns_buffer_status(output);
2047 return ldns_buffer_status(output);
2106 return ldns_buffer_status(output);
2112 ldns_edns_hex_data2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2115 for (j = 0; j < len; j++) {
2121 ldns_edns_llq2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2124 const char* llq_errors[] = {
"NO-ERROR",
"SERV-FULL",
"STATIC",
2125 "FORMAT-ERR",
"NO-SUCH-LLQ",
"BAD-VERS",
"UNKNOWN_ERR"};
2126 const unsigned int llq_errors_num = 7;
2127 const char* llq_opcodes[] = {
"LLQ-SETUP",
"LLQ-REFRESH",
"LLQ-EVENT"};
2128 const unsigned int llq_opcodes_num = 3;
2130 uint16_t version, llq_opcode, error_code;
2132 uint32_t lease_life;
2139 ldns_edns_hex_data2buffer_str(output, data, len);
2141 return ldns_buffer_status(output);
2143 version = ldns_read_uint16(data);
2144 llq_opcode = ldns_read_uint16(data+2);
2145 error_code = ldns_read_uint16(data+4);
2146 memmove(&llq_id, data+6,
sizeof(uint64_t));
2147 lease_life = ldns_read_uint32(data+14);
2152 if(llq_opcode < llq_opcodes_num) {
2158 if(error_code < llq_errors_num)
2166 (
unsigned long long)llq_id, (
unsigned long)lease_life);
2169 (
unsigned long long)llq_id, (
unsigned long)lease_life);
2171 return ldns_buffer_status(output);
2176 ldns_edns_ul2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2184 ldns_edns_hex_data2buffer_str(output, data, len);
2185 return ldns_buffer_status(output);
2187 lease = ldns_read_uint32(data);
2190 return ldns_buffer_status(output);
2194 ldns_edns_nsid2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2196 size_t i, printed=0;
2199 ldns_edns_hex_data2buffer_str(output, data, len);
2202 for(i = 0; i < len; i++) {
2203 if(isprint((
unsigned char)data[i]) || data[i] ==
'\t') {
2213 return ldns_buffer_status(output);
2218 ldns_edns_dau2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2225 for(i = 0; i <len; i++) {
2227 if (lt && lt->
name) {
2233 return ldns_buffer_status(output);
2237 ldns_edns_dhu2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2244 for(i = 0; i < len; i++) {
2246 if (lt && lt->
name) {
2252 return ldns_buffer_status(output);
2256 ldns_edns_d3u2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2262 for(i=0; i<len; i++) {
2269 return ldns_buffer_status(output);
2273 ldns_edns_subnet2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2276 uint8_t source, scope;
2279 ldns_edns_hex_data2buffer_str(output, data, len);
2280 return ldns_buffer_status(output);
2282 family = ldns_read_uint16(data);
2289 memset(ip4, 0,
sizeof(ip4));
2292 ldns_edns_hex_data2buffer_str(output, data+4+4, len-4-4);
2296 memmove(ip4, data+4, len-4);
2297 if(!inet_ntop(AF_INET, ip4, buf, (socklen_t)
sizeof(buf))) {
2299 ldns_edns_hex_data2buffer_str(output, data+4+4, len-4-4);
2303 }
else if(family == 2) {
2307 memset(ip6, 0,
sizeof(ip6));
2310 ldns_edns_hex_data2buffer_str(output, data+4+16, len-4-16);
2314 memmove(ip6, data+4, len-4);
2316 if(!inet_ntop(AF_INET6, ip6, buf, (socklen_t)
sizeof(buf))) {
2318 ldns_edns_hex_data2buffer_str(output, data+4+4, len-4-4);
2323 ldns_edns_hex_data2buffer_str(output, data+4+4, len-4-4);
2328 ldns_edns_hex_data2buffer_str(output, data, len);
2332 return ldns_buffer_status(output);
2336 ldns_edns_expire2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2341 if (!(len == 0) || len == 4) {
2343 ldns_edns_hex_data2buffer_str(output, data, len);
2345 return ldns_buffer_status(output);
2349 ldns_edns_hex_data2buffer_str(output, data, len);
2351 return ldns_buffer_status(output);
2356 ldns_edns_cookie2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2361 if (!(len == 8 || (len >= 16 && len < 40))) {
2363 ldns_edns_hex_data2buffer_str(output, data, len);
2365 ldns_edns_hex_data2buffer_str(output, data, len);
2367 return ldns_buffer_status(output);
2371 ldns_edns_keepalive2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2377 if(!(len == 0 || len == 2)) {
2379 ldns_edns_hex_data2buffer_str(output, data, len);
2381 return ldns_buffer_status(output);
2387 timeout = ldns_read_uint16(data);
2390 return ldns_buffer_status(output);
2394 ldns_edns_padding2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2397 ldns_edns_hex_data2buffer_str(output, data, len);
2399 return ldns_buffer_status(output);
2403 ldns_edns_chain2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2411 ldns_edns_hex_data2buffer_str(output, data, len);
2413 return ldns_buffer_status(output);
2416 ldns_characters2buffer_str(output, len, data);
2418 return ldns_buffer_status(output);
2422 ldns_edns_key_tag2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2428 if(len < 2 || len % 2 != 0) {
2430 ldns_edns_hex_data2buffer_str(output, data, len);
2432 return ldns_buffer_status(output);
2435 for (i = 0; i < len; i += 2) {
2436 uint16_t tag = ldns_read_uint16(data);
2441 return ldns_buffer_status(output);
2445 ldns_edns_ede2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2453 ldns_edns_hex_data2buffer_str(output, data, len);
2455 return ldns_buffer_status(output);
2458 ede = ldns_read_uint16(data);
2555 for (i = 0; i < len; i++) {
2561 ldns_characters2buffer_str(output, len, data);
2565 return ldns_buffer_status(output);
2569 ldns_edns_client_tag2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2575 ldns_edns_hex_data2buffer_str(output, data, len);
2577 return ldns_buffer_status(output);
2580 ldns_edns_hex_data2buffer_str(output, data, len);
2582 return ldns_buffer_status(output);
2586 ldns_edns_server_tag2buffer_str(
ldns_buffer* output, uint8_t* data,
size_t len)
2592 ldns_edns_hex_data2buffer_str(output, data, len);
2594 return ldns_buffer_status(output);
2597 ldns_edns_hex_data2buffer_str(output, data, len);
2599 return ldns_buffer_status(output);
2609 for (i = 0; i < count; i++) {
2623 ldns_edns_llq2buffer_str(output, data, size);
2626 ldns_edns_ul2buffer_str(output, data, size);
2629 ldns_edns_nsid2buffer_str(output, data, size);
2632 ldns_edns_dau2buffer_str(output, data, size);
2635 ldns_edns_dhu2buffer_str(output, data, size);
2638 ldns_edns_d3u2buffer_str(output, data, size);
2641 ldns_edns_subnet2buffer_str(output, data, size);
2644 ldns_edns_expire2buffer_str(output, data, size);
2647 ldns_edns_cookie2buffer_str(output, data, size);
2650 ldns_edns_keepalive2buffer_str(output, data, size);
2653 ldns_edns_padding2buffer_str(output, data, size);
2656 ldns_edns_chain2buffer_str(output, data, size);
2659 ldns_edns_key_tag2buffer_str(output, data, size);
2662 ldns_edns_ede2buffer_str(output, data, size);
2665 ldns_edns_client_tag2buffer_str(output, data, size);
2668 ldns_edns_server_tag2buffer_str(output, data, size);
2672 ldns_edns_hex_data2buffer_str(output, data, size);
2678 return ldns_buffer_status(output);
2689 struct timeval time;
2698 if (!ldns_buffer_status_ok(output)) {
2699 return ldns_buffer_status(output);
2764 ";; EDNS: version %u; flags:",
2806 time_tt = (time_t)time.tv_sec;
2808 (
char*)ctime(&time_tt));
2842 #if defined(HAVE_SSL) && defined(USE_GOST)
2844 ldns_gost_key2buffer_str(
ldns_buffer *output, EVP_PKEY *p)
2846 unsigned char* pp = NULL;
2853 ret = i2d_PrivateKey(p, &pp);
2864 #if defined(HAVE_SSL) && defined(USE_ED25519)
2866 ldns_ed25519_key2buffer_str(
ldns_buffer *output, EVP_PKEY *p)
2868 unsigned char* pp = NULL;
2875 ret = i2d_PrivateKey(p, &pp);
2877 if(ret != 16 + 32) {
2882 (
size_t)ret-16, pp+16);
2892 #if defined(HAVE_SSL) && defined(USE_ED448)
2894 ldns_ed448_key2buffer_str(
ldns_buffer *output, EVP_PKEY *p)
2896 unsigned char* pp = NULL;
2903 ret = i2d_PrivateKey(p, &pp);
2905 if(ret != 16 + 57) {
2910 (
size_t)ret-16, pp+16);
2920 #if defined(HAVE_SSL)
2923 ldns_print_bignum_b64_line(
ldns_buffer* output,
const char* label,
const BIGNUM* num)
2926 if(!bignumbuf)
return 0;
2931 int i = BN_bn2bin(num, bignumbuf);
2956 unsigned char *bignum;
2973 if (ldns_buffer_status_ok(output)) {
2989 "Algorithm: %u (RSA)\n",
2994 "Algorithm: %u (RSASHA1)\n",
2999 "Algorithm: %u (RSASHA1_NSEC3)\n",
3005 "Algorithm: %u (RSASHA256)\n",
3010 "Algorithm: %u (RSASHA512)\n",
3016 fprintf(stderr,
"Warning: unknown signature ");
3018 "algorithm type %u\n",
3022 "Algorithm: %u (Unknown)\n",
3032 const BIGNUM *n=NULL, *e=NULL, *d=NULL,
3033 *p=NULL, *q=NULL, *dmp1=NULL,
3034 *dmq1=NULL, *iqmp=NULL;
3035 #if OPENSSL_VERSION_NUMBER < 0x10100000 || (defined(HAVE_LIBRESSL) && LIBRESSL_VERSION_NUMBER < 0x20700000)
3045 RSA_get0_key(rsa, &n, &e, &d);
3046 RSA_get0_factors(rsa, &p, &q);
3047 RSA_get0_crt_params(rsa, &dmp1,
3050 if(!ldns_print_bignum_b64_line(output,
"Modulus", n))
3052 if(!ldns_print_bignum_b64_line(output,
"PublicExponent", e))
3054 if(!ldns_print_bignum_b64_line(output,
"PrivateExponent", d))
3056 if(!ldns_print_bignum_b64_line(output,
"Prime1", p))
3058 if(!ldns_print_bignum_b64_line(output,
"Prime2", q))
3060 if(!ldns_print_bignum_b64_line(output,
"Exponent1", dmp1))
3062 if(!ldns_print_bignum_b64_line(output,
"Exponent2", dmq1))
3064 if(!ldns_print_bignum_b64_line(output,
"Coefficient", iqmp))
3086 const BIGNUM *p=NULL, *q=NULL, *g=NULL,
3087 *priv_key=NULL, *pub_key=NULL;
3088 #if OPENSSL_VERSION_NUMBER < 0x10100000 || (defined(HAVE_LIBRESSL) && LIBRESSL_VERSION_NUMBER < 0x20700000)
3093 priv_key = dsa->priv_key;
3094 pub_key = dsa->pub_key;
3097 DSA_get0_pqg(dsa, &p, &q, &g);
3098 DSA_get0_key(dsa, &pub_key, &priv_key);
3100 if(!ldns_print_bignum_b64_line(output,
"Prime(p)", p))
3102 if(!ldns_print_bignum_b64_line(output,
"Subprime(q)", q))
3104 if(!ldns_print_bignum_b64_line(output,
"Base(g)", g))
3106 if(!ldns_print_bignum_b64_line(output,
"Private_value(x)", priv_key))
3108 if(!ldns_print_bignum_b64_line(output,
"Public_value(y)", pub_key))
3115 #if defined(HAVE_SSL) && defined(USE_GOST)
3118 status = ldns_gost_key2buffer_str(output,
3138 EC_KEY* ec = EVP_PKEY_get1_EC_KEY(k->
_key.
key);
3139 const BIGNUM* b = EC_KEY_get0_private_key(ec);
3140 if(!ldns_print_bignum_b64_line(output,
"PrivateKey", b))
3158 status = ldns_ed25519_key2buffer_str(output,
3169 status = ldns_ed448_key2buffer_str(output,
3178 status = ldns_hmac_key2buffer_str(output, k);
3183 status = ldns_hmac_key2buffer_str(output, k);
3188 status = ldns_hmac_key2buffer_str(output, k);
3193 status = ldns_hmac_key2buffer_str(output, k);
3198 status = ldns_hmac_key2buffer_str(output, k);
3203 status = ldns_hmac_key2buffer_str(output, k);
3209 return ldns_buffer_status(output);
3233 if (*(ldns_buffer_at(buffer, ldns_buffer_position(buffer))) != 0) {
3237 ldns_buffer_write_char(buffer, (uint8_t)
'\0');
3243 str = strdup((
const char *)ldns_buffer_begin(buffer));
3260 ldns_buffer_write_char(buffer, 0);
3270 char *result = NULL;
3287 char *result = NULL;
3311 char *result = NULL;
3336 char *result = NULL;
3353 char *result = NULL;
3361 tmp_buffer, fmt, list)
3390 fprintf(output,
"%s", str);
3392 fprintf(output,
";Unable to convert rdf to string\n");
3403 fprintf(output,
"%s", str);
3405 fprintf(output,
";Unable to convert rr to string\n");
3422 fprintf(output,
"%s", str);
3424 fprintf(output,
";Unable to convert packet to string\n");
3481 fprintf(output,
"trust anchors (%d listed):\n",
3484 fprintf(output,
"tsig: %s %s\n",
3489 fprintf(output,
"default domain: ");
3491 fprintf(output,
"\n");
3496 fprintf(output,
"\t");
3498 fprintf(output,
"\n");
3504 fprintf(output,
"\t");
3507 switch ((
int)rtt[i]) {
3509 fprintf(output,
" - reachable\n");
3512 fprintf(output,
" - unreachable\n");
void ldns_buffer_free(ldns_buffer *buffer)
frees the buffer.
bool ldns_buffer_set_capacity(ldns_buffer *buffer, size_t capacity)
changes the buffer's capacity.
bool 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.
uint16_t ldns_calc_keytag(const ldns_rr *key)
calculates a keytag of a key for use in DNSSEC.
bool 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.
bool 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.
uint8_t * ldns_edns_get_data(const ldns_edns_option *edns)
returns the EDNS option data.
ldns_edns_option_code ldns_edns_get_code(const ldns_edns_option *edns)
returns the option code of the EDNS data.
size_t ldns_edns_option_list_get_count(const ldns_edns_option_list *option_list)
returns the number of options in the EDNS options list.
size_t ldns_edns_get_size(const ldns_edns_option *edns)
returns the size of the EDNS data.
void ldns_edns_option_list_deep_free(ldns_edns_option_list *option_list)
ldns_edns_option * ldns_edns_option_list_get_option(const ldns_edns_option_list *option_list, size_t index)
returns the EDNS option as the specified index in the list of EDNS options.
@ 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
enum ldns_enum_edns_option ldns_edns_option_code
@ 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.
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)
ldns_edns_option_list * pkt_edns_data2edns_option_list(const ldns_rdf *edns_data)
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
RSA * ldns_key_rsa_key(const ldns_key *k)
returns the (openssl) RSA struct contained in the key
DSA * ldns_key_dsa_key(const ldns_key *k)
returns the (openssl) DSA struct contained in the key
@ LDNS_SIGN_ECDSAP256SHA256
@ LDNS_SIGN_RSASHA1_NSEC3
@ LDNS_SIGN_ECDSAP384SHA384
#define LDNS_KEY_ZONE_KEY
enum ldns_enum_algorithm ldns_algorithm
Including this file will include all ldns files, and define some lookup tables.
uint8_t ldns_pkt_edns_version(const ldns_pkt *packet)
return the packet's edns version
ldns_rdf * ldns_pkt_answerfrom(const ldns_pkt *packet)
Return the packet's answerfrom.
ldns_pkt_opcode ldns_pkt_get_opcode(const ldns_pkt *packet)
Read the packet's code.
ldns_rr_list * ldns_pkt_question(const ldns_pkt *packet)
Return the packet's question section.
uint16_t ldns_pkt_id(const ldns_pkt *packet)
Read the packet id.
uint16_t ldns_pkt_arcount(const ldns_pkt *packet)
Return the packet's ar count.
struct timeval ldns_pkt_timestamp(const ldns_pkt *packet)
Return the packet's timestamp.
bool ldns_pkt_qr(const ldns_pkt *packet)
Read the packet's qr bit.
bool ldns_pkt_edns(const ldns_pkt *pkt)
returns true if this packet needs and EDNS rr to be sent.
ldns_rr_list * ldns_pkt_authority(const ldns_pkt *packet)
Return the packet's authority section.
uint16_t ldns_pkt_ancount(const ldns_pkt *packet)
Return the packet's an count.
bool ldns_pkt_cd(const ldns_pkt *packet)
Read the packet's cd bit.
ldns_rr_list * ldns_pkt_additional(const ldns_pkt *packet)
Return the packet's additional section.
size_t ldns_pkt_size(const ldns_pkt *packet)
Return the packet's size in bytes.
bool ldns_pkt_ad(const ldns_pkt *packet)
Read the packet's ad bit.
uint32_t ldns_pkt_querytime(const ldns_pkt *packet)
Return the packet's querytime.
bool ldns_pkt_rd(const ldns_pkt *packet)
Read the packet's rd bit.
uint8_t ldns_pkt_edns_extended_rcode(const ldns_pkt *packet)
return the packet's edns extended rcode
bool ldns_pkt_ra(const ldns_pkt *packet)
Read the packet's ra bit.
ldns_rr_list * ldns_pkt_answer(const ldns_pkt *packet)
Return the packet's answer section.
uint16_t ldns_pkt_nscount(const ldns_pkt *packet)
Return the packet's ns count.
uint16_t ldns_pkt_qdcount(const ldns_pkt *packet)
Return the packet's qd count.
ldns_rdf * ldns_pkt_edns_data(const ldns_pkt *packet)
return the packet's EDNS data
ldns_rr * ldns_pkt_tsig(const ldns_pkt *pkt)
Return the packet's tsig pseudo rr's.
bool ldns_pkt_edns_do(const ldns_pkt *packet)
return the packet's edns do bit
bool ldns_pkt_aa(const ldns_pkt *packet)
Read the packet's aa bit.
ldns_pkt_rcode ldns_pkt_get_rcode(const ldns_pkt *packet)
Return the packet's response code.
bool ldns_pkt_tc(const ldns_pkt *packet)
Read the packet's tc bit.
uint16_t ldns_pkt_edns_udp_size(const ldns_pkt *packet)
return the packet's edns udp size
#define LDNS_MAX_PACKETLEN
enum ldns_enum_pkt_rcode ldns_pkt_rcode
enum ldns_enum_pkt_opcode ldns_pkt_opcode
ldns_rbnode_t * ldns_rbtree_search(ldns_rbtree_t *rbtree, const void *key)
Find key in tree.
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.
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_rdf * ldns_rdf_new_frm_data(ldns_rdf_type type, size_t size, const void *data)
allocates a new rdf structure and fills it.
enum ldns_enum_cert_algorithm ldns_cert_algorithm
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
@ LDNS_SVCPARAM_KEY_MANDATORY
@ LDNS_SVCPARAM_KEY_IPV4HINT
@ LDNS_SVCPARAM_KEY_IPV6HINT
@ LDNS_SVCPARAM_KEY_NO_DEFAULT_ALPN
const char * ldns_resolver_tsig_algorithm(const ldns_resolver *r)
Return the tsig algorithm as used by the nameserver.
bool ldns_resolver_dnssec(const ldns_resolver *r)
Does the resolver do DNSSEC.
bool ldns_resolver_usevc(const ldns_resolver *r)
Does the resolver use tcp or udp.
bool ldns_resolver_debug(const ldns_resolver *r)
Get the debug status of the resolver.
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.
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.
bool ldns_resolver_dnssec_cd(const ldns_resolver *r)
Does the resolver set the CD bit.
bool ldns_resolver_recursive(const ldns_resolver *r)
Is the resolver set to recurse.
bool ldns_resolver_dnsrch(const ldns_resolver *r)
Does the resolver apply search list.
bool ldns_resolver_igntc(const ldns_resolver *r)
Does the resolver ignore the TC bit (truncated)
bool 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.
bool ldns_resolver_random(const ldns_resolver *r)
Does the resolver randomize the nameserver before usage.
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.
bool ldns_resolver_fallback(const ldns_resolver *r)
Get the truncation fallback status.
uint8_t ldns_resolver_ip6(const ldns_resolver *r)
Does the resolver use ip6 or ip4.
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.
bool ldns_resolver_fail(const ldns_resolver *r)
Does the resolver only try the first nameserver.
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.
uint16_t ldns_resolver_port(const ldns_resolver *r)
Get the port the resolver should use.
#define LDNS_RESOLV_RTT_MIN
#define LDNS_RESOLV_RTT_INF
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.
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.
bool ldns_rr_is_question(const ldns_rr *rr)
returns the question flag of an rr structure.
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.
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.
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)
enum ldns_enum_rr_class ldns_rr_class
#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.
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 **d, 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, size_t src_sz, char *dst, size_t dst_sz)
ldns_lookup_table * ldns_lookup_by_id(ldns_lookup_table *table, int id)
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...
#define LDNS_XMALLOC(type, count)
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.