19 #ifdef HAVE_SYS_SOCKET_H 20 #include <sys/socket.h> 22 #ifdef HAVE_ARPA_INET_H 23 #include <arpa/inet.h> 31 #ifndef INET_ADDRSTRLEN 32 #define INET_ADDRSTRLEN 16 34 #ifndef INET6_ADDRSTRLEN 35 #define INET6_ADDRSTRLEN 46 61 { LDNS_ED25519,
"ED25519"},
64 { LDNS_ED448,
"ED448"},
192 if (lt && lt->
name) {
197 return ldns_buffer_status(output);
204 if (lt && lt->
name) {
209 return ldns_buffer_status(output);
218 if (lt && lt->
name) {
223 return ldns_buffer_status(output);
232 if (lt && lt->
name) {
238 return ldns_buffer_status(output);
349 for(i = 0; i < len; i++) {
353 c = (
unsigned char) data[src_pos];
354 if(c ==
'.' || c ==
';' ||
355 c ==
'(' || c ==
')' ||
359 }
else if (!(isascii(c) && isgraph(c))) {
374 return ldns_buffer_status(output);
382 return ldns_buffer_status(output);
390 return ldns_buffer_status(output);
398 return ldns_buffer_status(output);
408 memset(&tm, 0,
sizeof(tm));
410 && strftime(date_buf, 15,
"%Y%m%d%H%M%S", &tm)) {
413 return ldns_buffer_status(output);
424 return ldns_buffer_status(output);
436 return ldns_buffer_status(output);
441 size_t amount,
const uint8_t* characters)
446 if (isprint((
int)ch) || ch ==
'\t') {
447 if (ch ==
'\"' || ch ==
'\\')
453 (
unsigned)(uint8_t) ch);
469 ldns_characters2buffer_str(output,
472 return ldns_buffer_status(output);
478 size_t size = ldns_b64_ntop_calculate_size(
ldns_rdf_size(rdf));
485 return ldns_buffer_status(output);
506 return ldns_buffer_status(output);
517 return ldns_buffer_status(output);
526 if (! ldns_output_format_covers_type(fmt, data) &&
534 return ldns_buffer_status(output);
540 return ldns_rdf2buffer_str_type_fmt(output,
556 return ldns_buffer_status(output);
570 return ldns_buffer_status(output);
580 loc_cm_print(
ldns_buffer *output, uint8_t mantissa, uint8_t exponent)
592 for(i=0; i<exponent-2; i++)
620 if (descriptor && descriptor->
_name) {
626 return ldns_buffer_status(output);
662 return ldns_buffer_status(output);
690 uint8_t horizontal_precision;
691 uint8_t vertical_precision;
701 uint32_t equator = (uint32_t) ldns_power(2, 31);
719 if (latitude > equator) {
721 latitude = latitude - equator;
724 latitude = equator - latitude;
726 h = latitude / (1000 * 60 * 60);
727 latitude = latitude % (1000 * 60 * 60);
728 m = latitude / (1000 * 60);
729 latitude = latitude % (1000 * 60);
730 s = (double) latitude / 1000.0;
732 h, m, s, northerness);
734 if (longitude > equator) {
736 longitude = longitude - equator;
739 longitude = equator - longitude;
741 h = longitude / (1000 * 60 * 60);
742 longitude = longitude % (1000 * 60 * 60);
743 m = longitude / (1000 * 60);
744 longitude = longitude % (1000 * 60);
745 s = (double) longitude / (1000.0);
747 h, m, s, easterness);
750 s = ((double) altitude) / 100;
753 if(altitude%100 != 0)
760 loc_cm_print(output, (size & 0xf0) >> 4, size & 0x0f);
763 loc_cm_print(output, (horizontal_precision & 0xf0) >> 4,
764 horizontal_precision & 0x0f);
767 loc_cm_print(output, (vertical_precision & 0xf0) >> 4,
768 vertical_precision & 0x0f);
771 return ldns_buffer_status(output);
801 struct protoent *protocol;
802 char *proto_name = NULL;
804 struct servent *service;
805 uint16_t current_service;
811 protocol = getprotobynumber((
int) protocol_nr);
812 if (protocol && (protocol->p_name != NULL)) {
813 proto_name = protocol->p_name;
819 #ifdef HAVE_ENDPROTOENT 823 for (current_service = 0;
824 current_service < (
ldns_rdf_size(rdf)-1)*8; current_service++) {
826 service = getservbyport((
int) htons(current_service),
828 if (service && service->s_name) {
833 #ifdef HAVE_ENDSERVENT 838 return ldns_buffer_status(output);
848 uint8_t window_block_nr;
849 uint8_t bitmap_length;
856 window_block_nr = data[pos];
857 bitmap_length = data[pos + 1];
862 for (bit_pos = 0; bit_pos < (bitmap_length) * 8; bit_pos++) {
866 type = 256 * (uint16_t) window_block_nr + bit_pos;
868 if (! ldns_output_format_covers_type(fmt, type) &&
878 pos += (uint16_t) bitmap_length;
880 return ldns_buffer_status(output);
886 return ldns_rdf2buffer_str_nsec_fmt(output,
901 salt_length = data[0];
903 if (salt_length == 0 || ((
size_t)salt_length)+1 >
ldns_rdf_size(rdf)) {
906 for (salt_pos = 0; salt_pos < salt_length; salt_pos++) {
912 return ldns_buffer_status(output);
923 return ldns_buffer_status(output);
930 uint64_t tsigtime = 0;
932 uint64_t d0, d1, d2, d3, d4, d5;
943 tsigtime = (d0<<40) | (d1<<32) | (d2<<24) | (d3<<16) | (d4<<8) | d5;
947 return ldns_buffer_status(output);
954 uint16_t address_family;
964 address_family = ldns_read_uint16(&data[pos]);
965 prefix = data[pos + 2];
975 for (i = 0; i < 4; i++) {
979 if (i < (
unsigned short) adf_length) {
996 for (i = 0; i < 16; i++) {
997 if (i % 2 == 0 && i > 0) {
1000 if (i < (
unsigned short) adf_length) {
1014 "Unknown address family: %u data: ",
1016 for (i = 1; i < (
unsigned short) (4 + adf_length); i++) {
1022 pos += 4 + adf_length;
1024 return ldns_buffer_status(output);
1036 size = ldns_b64_ntop_calculate_size(
ldns_rdf_size(rdf) - 2);
1051 return ldns_buffer_status(output);
1062 uint8_t gateway_type;
1066 uint8_t *gateway_data;
1068 size_t public_key_size;
1069 uint8_t *public_key_data;
1078 precedence = data[0];
1079 gateway_type = data[1];
1080 algorithm = data[2];
1083 switch (gateway_type) {
1135 public_key_data =
LDNS_XMALLOC(uint8_t, public_key_size);
1136 if(!public_key_data) {
1140 memcpy(public_key_data, &data[offset], public_key_size);
1142 public_key_size, public_key_data);
1160 return ldns_buffer_status(output);
1174 return ldns_buffer_status(output);
1187 return ldns_buffer_status(output);
1201 return ldns_buffer_status(output);
1208 const uint8_t* chars;
1219 while (nchars > 0) {
1220 ch = (char)*chars++;
1221 if (! isalnum((
unsigned char)ch)) {
1227 return ldns_buffer_status(output);
1235 ldns_characters2buffer_str(output,
1238 return ldns_buffer_status(output);
1253 if ((hit_size = data[0]) == 0 ||
1254 (pk_size = ldns_read_uint16(data + 2)) == 0 ||
1255 rdf_size < (
size_t) hit_size + pk_size + 4) {
1262 for (data += 4; hit_size > 0; hit_size--, data++) {
1266 ldns_buffer_write_u8(output, (uint8_t)
' ');
1269 ldns_b64_ntop_calculate_size(pk_size))) {
1272 (
char *) ldns_buffer_current(output),
1273 ldns_buffer_remaining(output));
1276 written < (
int) ldns_buffer_remaining(output)) {
1281 return ldns_buffer_status(output);
1339 res = ldns_rdf2buffer_str_nsec_fmt(buffer, fmt, rdf);
1345 res = ldns_rdf2buffer_str_type_fmt(buffer, fmt, rdf);
1415 ldns_b32_ext2dname(
const ldns_rdf *rdf)
1423 size = ldns_b32_ntop_calculate_size(
ldns_rdf_size(rdf) - 1);
1444 size_t total_rdfsize = 0;
1451 if (total_rdfsize == 0) {
1453 return ldns_buffer_status(output);
1463 return ldns_buffer_status(output);
1474 if (fmt_st == NULL) {
1482 return ldns_buffer_status(output);
1504 return ldns_rr2buffer_str_rfc3597(output, rr);
1532 status = ldns_buffer_status(output);
1539 (
unsigned long) ldns_read_uint32(
1541 status = ldns_buffer_status(output);
1543 status = ldns_rdf2buffer_str_fmt(output,
1580 }
else if (fmt_st->
flags 1654 key = ldns_b32_ext2dname(
1682 return ldns_buffer_status(output);
1701 return ldns_buffer_status(output);
1760 return ldns_buffer_status(output);
1770 struct timeval time;
1778 if (ldns_buffer_status_ok(output)) {
1839 ";; EDNS: version %u; flags:",
1872 time_tt = (time_t)time.tv_sec;
1874 (
char*)ctime(&time_tt));
1879 return ldns_buffer_status(output);
1910 #if defined(HAVE_SSL) && defined(USE_GOST) 1912 ldns_gost_key2buffer_str(
ldns_buffer *output, EVP_PKEY *p)
1914 unsigned char* pp = NULL;
1921 ret = i2d_PrivateKey(p, &pp);
1934 ldns_print_bignum_b64_line(
ldns_buffer* output,
const char* label,
const BIGNUM* num)
1937 if(!bignumbuf)
return 0;
1942 int i = BN_bn2bin(num, bignumbuf);
1966 unsigned char *bignum;
1981 if (ldns_buffer_status_ok(output)) {
1997 "Algorithm: %u (RSA)\n",
2002 "Algorithm: %u (RSASHA1)\n",
2007 "Algorithm: %u (RSASHA1_NSEC3)\n",
2013 "Algorithm: %u (RSASHA256)\n",
2018 "Algorithm: %u (RSASHA512)\n",
2024 fprintf(stderr,
"Warning: unknown signature ");
2026 "algorithm type %u\n",
2030 "Algorithm: %u (Unknown)\n",
2040 const BIGNUM *n=NULL, *e=NULL, *d=NULL,
2041 *p=NULL, *q=NULL, *dmp1=NULL,
2042 *dmq1=NULL, *iqmp=NULL;
2043 #if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(HAVE_LIBRESSL) 2053 RSA_get0_key(rsa, &n, &e, &d);
2054 RSA_get0_factors(rsa, &p, &q);
2055 RSA_get0_crt_params(rsa, &dmp1,
2058 if(!ldns_print_bignum_b64_line(output,
"Modulus", n))
2060 if(!ldns_print_bignum_b64_line(output,
"PublicExponent", e))
2062 if(!ldns_print_bignum_b64_line(output,
"PrivateExponent", d))
2064 if(!ldns_print_bignum_b64_line(output,
"Prime1", p))
2066 if(!ldns_print_bignum_b64_line(output,
"Prime2", q))
2068 if(!ldns_print_bignum_b64_line(output,
"Exponent1", dmp1))
2070 if(!ldns_print_bignum_b64_line(output,
"Exponent2", dmq1))
2072 if(!ldns_print_bignum_b64_line(output,
"Coefficient", iqmp))
2093 const BIGNUM *p=NULL, *q=NULL, *g=NULL,
2094 *priv_key=NULL, *pub_key=NULL;
2095 #if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(HAVE_LIBRESSL) 2100 priv_key = dsa->priv_key;
2101 pub_key = dsa->pub_key;
2104 DSA_get0_pqg(dsa, &p, &q, &g);
2105 DSA_get0_key(dsa, &pub_key, &priv_key);
2107 if(!ldns_print_bignum_b64_line(output,
"Prime(p)", p))
2109 if(!ldns_print_bignum_b64_line(output,
"Subprime(q)", q))
2111 if(!ldns_print_bignum_b64_line(output,
"Base(g)", g))
2113 if(!ldns_print_bignum_b64_line(output,
"Private_value(x)", priv_key))
2115 if(!ldns_print_bignum_b64_line(output,
"Public_value(y)", pub_key))
2121 #if defined(HAVE_SSL) && defined(USE_GOST) 2124 status = ldns_gost_key2buffer_str(output,
2144 EC_KEY* ec = EVP_PKEY_get1_EC_KEY(k->
_key.
key);
2145 const BIGNUM* b = EC_KEY_get0_private_key(ec);
2146 if(!ldns_print_bignum_b64_line(output,
"PrivateKey", b))
2158 case LDNS_SIGN_ED25519:
2164 EC_KEY* ec = EVP_PKEY_get1_EC_KEY(k->
_key.
key);
2165 const BIGNUM* b = EC_KEY_get0_private_key(ec);
2166 if(!ldns_print_bignum_b64_line(output,
"PrivateKey", b))
2176 case LDNS_SIGN_ED448:
2182 EC_KEY* ec = EVP_PKEY_get1_EC_KEY(k->
_key.
key);
2183 const BIGNUM* b = EC_KEY_get0_private_key(ec);
2184 if(!ldns_print_bignum_b64_line(output,
"PrivateKey", b))
2198 status = ldns_hmac_key2buffer_str(output, k);
2203 status = ldns_hmac_key2buffer_str(output, k);
2208 status = ldns_hmac_key2buffer_str(output, k);
2213 status = ldns_hmac_key2buffer_str(output, k);
2218 status = ldns_hmac_key2buffer_str(output, k);
2223 status = ldns_hmac_key2buffer_str(output, k);
2229 return ldns_buffer_status(output);
2253 if (*(ldns_buffer_at(buffer, ldns_buffer_position(buffer))) != 0) {
2257 ldns_buffer_write_u8(buffer, (uint8_t)
'\0');
2263 str = strdup((
const char *)ldns_buffer_begin(buffer));
2280 ldns_buffer_write_u8(buffer, 0);
2290 char *result = NULL;
2307 char *result = NULL;
2331 char *result = NULL;
2356 char *result = NULL;
2373 char *result = NULL;
2381 tmp_buffer, fmt, list)
2410 fprintf(output,
"%s", str);
2412 fprintf(output,
";Unable to convert rdf to string\n");
2423 fprintf(output,
"%s", str);
2425 fprintf(output,
";Unable to convert rr to string\n");
2442 fprintf(output,
"%s", str);
2444 fprintf(output,
";Unable to convert packet to string\n");
2501 fprintf(output,
"trust anchors (%d listed):\n",
2504 fprintf(output,
"tsig: %s %s\n",
2509 fprintf(output,
"default domain: ");
2511 fprintf(output,
"\n");
2516 fprintf(output,
"\t");
2518 fprintf(output,
"\n");
2524 fprintf(output,
"\t");
2527 switch ((
int)rtt[i]) {
2529 fprintf(output,
" - reachable\n");
2532 fprintf(output,
" - unreachable\n");
ldns_rdf * ldns_rr_rdf(const ldns_rr *rr, size_t nr)
returns the rdata field member counter.
uint8_t ldns_resolver_ip6(const ldns_resolver *r)
Does the resolver use ip6 or ip4.
implementation of buffers to ease operations
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.
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...
enum ldns_enum_cert_algorithm ldns_cert_algorithm
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...
bool ldns_resolver_dnsrch(const ldns_resolver *r)
Does the resolver apply search list.
uint16_t ldns_pkt_arcount(const ldns_pkt *packet)
Return the packet's ar count.
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...
ldns_rr * ldns_zone_soa(const ldns_zone *z)
Return the soa record of a zone.
void * ldns_buffer_export(ldns_buffer *buffer)
Makes the buffer fixed and returns a pointer to the data.
uint8_t ldns_resolver_retry(const ldns_resolver *r)
Get the number of retries.
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...
void ldns_rdf_deep_free(ldns_rdf *rd)
frees a rdf structure and frees the data.
#define LDNS_COMMENT_BUBBLEBABBLE
Provide bubblebabble representation for DS RR's as comment.
#define LDNS_COMMENT_KEY_TYPE
Show if a DNSKEY is a ZSK or KSK as comment.
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...
ldns_rr_list * ldns_pkt_question(const ldns_pkt *packet)
Return the packet's question section.
DNS stub resolver structure.
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...
char * ldns_bubblebabble(uint8_t *data, size_t len)
Encode data as BubbleBabble.
enum ldns_enum_rr_class ldns_rr_class
int ldns_buffer_printf(ldns_buffer *buffer, const char *format,...)
prints to the buffer, increasing the capacity if required using buffer_reserve(). ...
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_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...
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...
size_t ldns_resolver_searchlist_count(const ldns_resolver *r)
Return the resolver's searchlist count.
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...
List or Set of Resource Records.
ldns_status ldns_str2rdf_dname(ldns_rdf **d, const char *str)
convert a dname string into wireformat
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...
bool ldns_rr_is_question(const ldns_rr *rr)
returns the question flag of an rr structure.
bool ldns_pkt_tc(const ldns_pkt *packet)
Read the packet's tc bit.
ldns_pkt_rcode ldns_pkt_get_rcode(const ldns_pkt *packet)
Return the packet's respons code.
const ldns_output_format * ldns_output_format_onlykeyids
Standard output format record that annotated only DNSKEY RR's with commenti text. ...
int ldns_b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize)
A request for mailbox-related records (MB, MG or MR)
uint16_t ldns_pkt_qdcount(const ldns_pkt *packet)
Return the packet's qd count.
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...
bool ldns_resolver_dnssec(const ldns_resolver *r)
Does the resolver do DNSSEC.
uint8_t ldns_pkt_edns_extended_rcode(const ldns_pkt *packet)
return the packet's edns extended rcode
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...
uint16_t ldns_pkt_id(const ldns_pkt *packet)
Read the packet id.
struct tm * ldns_serial_arithmitics_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)
#define LDNS_COMMENT_NULLS
Represent a NULL pointer (instead of a pointer to a ldns_rr as "; (null)" as opposed to outputting no...
bool ldns_pkt_edns(const ldns_pkt *pkt)
returns true if this packet needs and EDNS rr to be sent.
DSA * ldns_key_dsa_key(const ldns_key *k)
returns the (openssl) DSA struct contained in the key
size_t ldns_rdf_size(const ldns_rdf *rd)
returns the size of the rdf.
ldns_lookup_table ldns_rcodes[]
Response codes.
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, HIT and Public Key and adds it the output buffer .
char * ldns_buffer2str(ldns_buffer *buffer)
Returns a copy of the data in the buffer as a null terminated char * string.
ldns_pkt_opcode ldns_pkt_get_opcode(const ldns_pkt *packet)
Read the packet's code.
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...
bool ldns_pkt_aa(const ldns_pkt *packet)
Read the packet's aa bit.
void ldns_buffer_free(ldns_buffer *buffer)
frees the buffer.
struct ldns_struct_key::@0 _key
Storage pointers for the types of keys supported.
uint32_t ldns_pkt_querytime(const ldns_pkt *packet)
Return the packet's querytime.
size_t ldns_rr_rd_count(const ldns_rr *rr)
returns the rd_count of an rr structure.
#define LDNS_FMT_PAD_SOA_SERIAL
#define LDNS_MAX_PACKETLEN
#define LDNS_COMMENT_KEY
Show key id, type and size as comment for DNSKEY RR's.
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...
ldns_lookup_table ldns_rr_classes[]
rr types
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...
uint16_t ldns_resolver_port(const ldns_resolver *r)
Get the port the resolver should use.
ldns_rdf ** ldns_resolver_searchlist(const ldns_resolver *r)
What is the searchlist as used by the resolver.
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_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.
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 *...
ldns_rr_list * ldns_resolver_dnssec_anchors(const ldns_resolver *r)
Get the resolver's DNSSEC anchors.
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...
char * ldns_rr_list2str(const ldns_rr_list *list)
Converts a list of resource records to presentation format and returns that as a char *...
void ldns_resolver_print(FILE *output, const ldns_resolver *r)
Print a resolver (in sofar that is possible) state to output.
bool ldns_resolver_dnssec_cd(const ldns_resolver *r)
Does the resolver set the CD 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.
const ldns_rr_descriptor * ldns_rr_descript(uint16_t type)
returns the resource record descriptor for the given rr type.
bool ldns_resolver_igntc(const ldns_resolver *r)
Does the resolver ignore the TC bit (truncated)
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 *...
protocol and port bitmaps
A non-zero sequence of US-ASCII letters and numbers in lower case.
const ldns_output_format * ldns_output_format_default
The default output format record.
A <character-string> encoding of the value field as specified [RFC1035], Section 5.1., encoded as remaining rdata.
#define LDNS_RESOLV_RTT_MIN
void ldns_rdf_free(ldns_rdf *rd)
frees a rdf structure, leaving the data pointer intact.
#define LDNS_COMMENT_KEY_SIZE
Show DNSKEY key size as comment.
size_t ldns_key_hmac_size(const ldns_key *k)
return the hmac key size
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) ...
const void * data
pointer to data
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_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...
bool ldns_resolver_defnames(const ldns_resolver *r)
Does the resolver apply default domain name.
Including this file will include all ldns files, and define some lookup tables.
bool ldns_resolver_fallback(const ldns_resolver *r)
Get the truncation fallback status.
marks the start of a zone of authority
uint16_t ldns_pkt_nscount(const ldns_pkt *packet)
Return the packet's ns count.
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...
General key structure, can contain all types of keys that are used in DNSSEC.
uint8_t * ldns_rdf_data(const ldns_rdf *rd)
returns the data of the rdf.
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_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_rdf * ldns_nsec3_next_owner(const ldns_rr *nsec3_rr)
Returns the first label of the next ownername in the NSEC3 chain (ie.
void ldns_rr_list_print(FILE *output, const ldns_rr_list *lst)
print a rr_list to output
ldns_rr * ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr)
returns a specific rr of an rrlist.
void ldns_zone_print_fmt(FILE *output, const ldns_output_format *fmt, const ldns_zone *z)
Print a zone structure * to output.
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) ...
Since RFC7218 TLSA records can be given with mnemonics, hence these rdata field types.
enum ldns_enum_pkt_opcode ldns_pkt_opcode
char * ldns_rr2str(const ldns_rr *rr)
Converts the data in the resource record to presentation format and returns that as a char *...
#define LDNS_MAX_DOMAINLEN
Maximum length of a complete dname.
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_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...
char * ldns_buffer_export2str(ldns_buffer *buffer)
Exports and returns the data in the buffer as a null terminated char * string.
uint16_t ldns_pkt_ancount(const ldns_pkt *packet)
Return the packet's an count.
bool ldns_resolver_usevc(const ldns_resolver *r)
Does the resolver use tcp or udp.
bool ldns_buffer_set_capacity(ldns_buffer *buffer, size_t capacity)
changes the buffer's capacity.
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_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.
size_t ldns_resolver_nameserver_count(const ldns_resolver *r)
How many nameserver are configured in the resolver.
The rbnode_t struct definition.
variable length any type rdata where the length is specified by the first 2 bytes ...
bool ldns_pkt_cd(const ldns_pkt *packet)
Read the packet's cd bit.
None class, dynamic update.
bool ldns_pkt_ra(const ldns_pkt *packet)
Read the packet's ra bit.
uint16_t ldns_rdf2native_int16(const ldns_rdf *rd)
returns the native uint16_t representation from the rdf.
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_algorithm2buffer_str(ldns_buffer *output, ldns_algorithm algorithm)
Converts an ldns algorithm type to its mnemonic, and adds that to the output buffer.
size_t _position
The current position used for reading/writing.
uint16_t ldns_resolver_edns_udp_size(const ldns_resolver *r)
Get the resolver's udp size.
ldns_lookup_table * ldns_lookup_by_id(ldns_lookup_table *table, int id)
ldns_lookup_table ldns_algorithms[]
Taken from RFC 2535, section 7.
#define LDNS_KEY_ZONE_KEY
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_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...
struct timeval ldns_pkt_timestamp(const ldns_pkt *packet)
Return the packet's timestamp.
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...
bool ldns_nsec3_optout(const ldns_rr *nsec3_rr)
Returns true if the opt-out flag has been set in the given NSEC3 RR.
uint16_t ldns_calc_keytag(const ldns_rr *key)
calculates a keytag of a key for use in DNSSEC.
ldns_rdf * ldns_pkt_answerfrom(const ldns_pkt *packet)
Return the packet's answerfrom.
enum ldns_enum_pkt_rcode ldns_pkt_rcode
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_dname(ldns_buffer *output, const ldns_rdf *dname)
Print the ldns_rdf containing a dname to the buffer.
RSA * ldns_key_rsa_key(const ldns_key *k)
returns the (openssl) RSA struct contained in the key
Contains all information about resource record types.
bool ldns_pkt_rd(const ldns_pkt *packet)
Read the packet's rd bit.
uint8_t ldns_pkt_edns_version(const ldns_pkt *packet)
return the packet's edns version
bool ldns_resolver_debug(const ldns_resolver *r)
Get the debug status of the resolver.
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.
ldns_rbnode_t * ldns_rbtree_search(ldns_rbtree_t *rbtree, const void *key)
Find key in tree.
#define LDNS_APL_NEGATION
ldns_rdf_type ldns_rdf_get_type(const ldns_rdf *rd)
returns the type of the rdf.
const ldns_output_format ldns_output_format_bubblebabble_record
ldns_lookup_table ldns_opcodes[]
Operation codes.
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) ...
uint32_t ldns_rdf2native_int32(const ldns_rdf *rd)
returns the native uint32_t representation from the rdf.
ldns_rr_type ldns_rr_get_type(const ldns_rr *rr)
returns the type of the rr.
bool ldns_resolver_random(const ldns_resolver *r)
Does the resolver randomize the nameserver before usage.
const char * ldns_resolver_tsig_algorithm(const ldns_resolver *r)
Return the tsig algorithm as used by the nameserver.
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_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...
const ldns_output_format ldns_output_format_onlykeyids_record
unsigned char * ldns_key_hmac_key(const ldns_key *k)
return the hmac key data
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...
const ldns_output_format * ldns_output_format_nocomments
Standard output format record that disables commenting in the textual representation of Resource Reco...
A request for mail agent RRs (Obsolete - see MX)
nsec3 base32 string (with length byte on wire
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 ...
enum ldns_enum_status ldns_status
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.
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.
ldns_buffer * ldns_buffer_new(size_t capacity)
creates a new buffer with the specified capacity.
ldns_rdf * ldns_rdf_new(ldns_rdf_type type, size_t size, void *data)
allocates a new rdf structure and fills it.
void ldns_zone_print(FILE *output, const ldns_zone *z)
Print a zone structure * to output.
A general purpose lookup table.
ldns_signing_algorithm ldns_key_algorithm(const ldns_key *k)
return the signing alg of the key
int ldns_b32_ntop_extended_hex(const uint8_t *src, size_t src_sz, char *dst, size_t dst_sz)
uint8_t ldns_resolver_retrans(const ldns_resolver *r)
Get the retransmit interval.
char * ldns_rr_class2str(const ldns_rr_class klass)
Converts an ldns_rr_class value to its string representation, and returns that string.
#define LDNS_FMT_ZEROIZE_RRSIGS
const ldns_output_format ldns_output_format_nocomments_record
size_t ldns_rr_dnskey_key_size(const ldns_rr *key)
get the length of the keydata in bits
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...
bool ldns_buffer_reserve(ldns_buffer *buffer, size_t amount)
ensures BUFFER can contain at least AMOUNT more bytes.
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) ...
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...
size_t * ldns_resolver_rtt(const ldns_resolver *r)
Return the used round trip times for the nameservers.
uint16_t ldns_pkt_edns_udp_size(const ldns_pkt *packet)
return the packet's edns udp size
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...
bool ldns_resolver_fail(const ldns_resolver *r)
Does the resolver only try the first nameserver.
#define LDNS_COMMENT_RRSIGS
Also comment KEY_ID with RRSIGS.
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...
ldns_rdf * ldns_dnssec_name_name(const ldns_dnssec_name *name)
Returns the domain name of the given dnssec_name structure.
4 shorts represented as 4 * 16 bit hex numbers separated by colons.
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_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_rdf * ldns_pkt_edns_data(const ldns_pkt *packet)
return the packet's edns data
#define LDNS_COMMENT_FLAGS
Show when a NSEC3 RR has the optout flag set as comment.
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.
char * ldns_rr_type2str(const ldns_rr_type type)
Converts an ldns_rr_type value to its string representation, and returns that string.
char * ldns_rdf2str(const ldns_rdf *rdf)
Converts the data in the rdata field to presentation format and returns that as a char *...
char * ldns_pkt_algorithm2str(ldns_algorithm algorithm)
Converts a signing algorithms to its mnemonic and returns that as an allocated null-terminated string...
ldns_rr_list * ldns_zone_rrs(const ldns_zone *z)
Get a list of a zone's content.
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_rdf ** ldns_resolver_nameservers(const ldns_resolver *r)
Return the configured nameserver ip address.
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_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...
bool ldns_pkt_qr(const ldns_pkt *packet)
Read the packet's qr bit.
Resource record data field.
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...
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...
ldns_rr * ldns_pkt_tsig(const ldns_pkt *pkt)
Return the packet's tsig pseudo rr's.
Represents the Public Key Algorithm, HIT and Public Key fields for the HIP RR types.
const ldns_output_format * ldns_output_format_bubblebabble
Standard output format record that shows all DNSKEY related information in the comment text...
ldns_lookup_table ldns_cert_algorithms[]
Taken from RFC 2538.
ldns_rdf * ldns_rr_owner(const ldns_rr *rr)
returns the owner name of an rr structure.
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...
size_t ldns_rr_list_rr_count(const ldns_rr_list *rr_list)
returns the number of rr's in an rr_list.
#define LDNS_COMMENT_KEY_ID
Show key id with DNSKEY RR's as comment.
enum ldns_enum_rr_type ldns_rr_type
bool ldns_pkt_ad(const ldns_pkt *packet)
Read the packet's ad bit.
const char * _name
Textual name of the RR type.
#define LDNS_COMMENT_NSEC3_CHAIN
Show the unhashed owner and next owner names for NSEC3 RR's as comment.
ldns_rr_list * ldns_pkt_authority(const ldns_pkt *packet)
Return the packet's authority section.
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.
size_t ldns_pkt_size(const ldns_pkt *packet)
Return the packet's size in bytes.
bool ldns_resolver_recursive(const ldns_resolver *r)
Is the resolver set to recurse.
#define LDNS_RESOLV_RTT_INF
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...
uint32_t ldns_rr_ttl(const ldns_rr *rr)
returns the ttl of an rr structure.
char * ldns_key2str(const ldns_key *k)
Converts a private key to the test presentation fmt and returns that as a char *. ...
ldns_rr_class ldns_rr_get_class(const ldns_rr *rr)
returns the class of the rr.
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.
const char * ldns_resolver_tsig_keyname(const ldns_resolver *r)
Return the tsig keyname as used by the nameserver.
ldns_rr_list * ldns_pkt_additional(const ldns_pkt *packet)
Return the packet's additional section.
ldns_rr_list * ldns_pkt_answer(const ldns_pkt *packet)
Return the packet's answer section.
8 * 8 bit hex numbers separated by dashes.
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...
6 * 8 bit hex numbers separated by dashes.
char * ldns_pkt2str(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_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_rdf_bitmap_known_rr_types(ldns_rdf **rdf)
Create a rr type bitmap rdf with at least all known (to ldns) rr types set.
ldns_rdf * ldns_resolver_domain(const ldns_resolver *r)
What is the default dname to add to relative queries.
enum ldns_enum_algorithm ldns_algorithm
bool ldns_pkt_edns_do(const ldns_pkt *packet)
return the packet's edns do bit
struct timeval ldns_resolver_timeout(const ldns_resolver *r)
What is the timeout on socket connections.
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_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...