/build/ldns-00A0O8/ldns-1.8.4/host2str.c
Go to the documentation of this file.
/*
* host2str.c
*
* conversion routines from the host format
* to the presentation format (strings)
*
* a Net::DNS like library for C
*
* (c) NLnet Labs, 2004-2006
*
* See the file LICENSE for the license
*/
#include <ldns/config.h>
#include <ldns/ldns.h>
#include <limits.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
#include <time.h>
#include <sys/time.h>
#ifdef HAVE_SSL
#include <openssl/bn.h>
#include <openssl/rsa.h>
#ifdef USE_DSA
#include <openssl/dsa.h>
#endif
#endif
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16
#endif
#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN 46
#endif
/* Internal helper function */
ldns_edns_option_list*
pkt_edns_data2edns_option_list(const ldns_rdf *edns_data);
/* lookup tables for standard DNS stuff */
/* Taken from RFC 2535, section 7. */
ldns_lookup_table ldns_algorithms[] = {
{ LDNS_RSAMD5, "RSAMD5" },
{ LDNS_DH, "DH" },
{ LDNS_DSA, "DSA" },
{ LDNS_ECC, "ECC" },
{ LDNS_RSASHA1, "RSASHA1" },
{ LDNS_DSA_NSEC3, "DSA-NSEC3-SHA1" },
{ LDNS_RSASHA1_NSEC3, "RSASHA1-NSEC3-SHA1" },
{ LDNS_RSASHA256, "RSASHA256"},
{ LDNS_RSASHA512, "RSASHA512"},
{ LDNS_ECC_GOST, "ECC-GOST"},
{ LDNS_ECDSAP256SHA256, "ECDSAP256SHA256"},
{ LDNS_ECDSAP384SHA384, "ECDSAP384SHA384"},
{ LDNS_ED25519, "ED25519"},
{ LDNS_ED448, "ED448"},
{ LDNS_INDIRECT, "INDIRECT" },
{ LDNS_PRIVATEDNS, "PRIVATEDNS" },
{ LDNS_PRIVATEOID, "PRIVATEOID" },
{ 0, NULL }
};
/* Hashing algorithms used in the DS record */
ldns_lookup_table ldns_hashes[] = {
{LDNS_SHA1 , "SHA1" }, /* RFC 4034 */
{LDNS_SHA256 , "SHA256" }, /* RFC 4509 */
{LDNS_HASH_GOST, "HASH-GOST" }, /* RFC 5933 */
{LDNS_SHA384 , "SHA384" }, /* RFC 6605 */
{ 0, NULL }
};
/* Taken from RFC 4398 */
ldns_lookup_table ldns_cert_algorithms[] = {
{ LDNS_CERT_PKIX, "PKIX" },
{ LDNS_CERT_SPKI, "SPKI" },
{ LDNS_CERT_PGP, "PGP" },
{ LDNS_CERT_IPKIX, "IPKIX" },
{ LDNS_CERT_ISPKI, "ISPKI" },
{ LDNS_CERT_IPGP, "IPGP" },
{ LDNS_CERT_ACPKIX, "ACPKIX" },
{ LDNS_CERT_IACPKIX, "IACPKIX" },
{ LDNS_CERT_URI, "URI" },
{ LDNS_CERT_OID, "OID" },
{ 0, NULL }
};
/* classes */
ldns_lookup_table ldns_rr_classes[] = {
{ LDNS_RR_CLASS_IN, "IN" },
{ LDNS_RR_CLASS_CH, "CH" },
{ LDNS_RR_CLASS_HS, "HS" },
{ LDNS_RR_CLASS_NONE, "NONE" },
{ LDNS_RR_CLASS_ANY, "ANY" },
{ 0, NULL }
};
/* if these are used elsewhere */
ldns_lookup_table ldns_rcodes[] = {
{ LDNS_RCODE_NOERROR, "NOERROR" },
{ LDNS_RCODE_FORMERR, "FORMERR" },
{ LDNS_RCODE_SERVFAIL, "SERVFAIL" },
{ LDNS_RCODE_NXDOMAIN, "NXDOMAIN" },
{ LDNS_RCODE_NOTIMPL, "NOTIMPL" },
{ LDNS_RCODE_REFUSED, "REFUSED" },
{ LDNS_RCODE_YXDOMAIN, "YXDOMAIN" },
{ LDNS_RCODE_YXRRSET, "YXRRSET" },
{ LDNS_RCODE_NXRRSET, "NXRRSET" },
{ LDNS_RCODE_NOTAUTH, "NOTAUTH" },
{ LDNS_RCODE_NOTZONE, "NOTZONE" },
{ 0, NULL }
};
ldns_lookup_table ldns_opcodes[] = {
{ LDNS_PACKET_QUERY, "QUERY" },
{ LDNS_PACKET_IQUERY, "IQUERY" },
{ LDNS_PACKET_STATUS, "STATUS" },
{ LDNS_PACKET_NOTIFY, "NOTIFY" },
{ LDNS_PACKET_UPDATE, "UPDATE" },
{ 0, NULL }
};
const ldns_output_format ldns_output_format_nocomments_record = { 0, NULL };
const ldns_output_format *ldns_output_format_nocomments
= &ldns_output_format_nocomments_record;
const ldns_output_format ldns_output_format_onlykeyids_record = {
LDNS_COMMENT_KEY, NULL
};
const ldns_output_format *ldns_output_format_onlykeyids
= &ldns_output_format_onlykeyids_record;
const ldns_output_format *ldns_output_format_default
= &ldns_output_format_onlykeyids_record;
const ldns_output_format ldns_output_format_bubblebabble_record = {
LDNS_COMMENT_KEY | LDNS_COMMENT_BUBBLEBABBLE | LDNS_COMMENT_FLAGS, NULL
};
const ldns_output_format *ldns_output_format_bubblebabble
= &ldns_output_format_bubblebabble_record;
static bool
ldns_output_format_covers_type(const ldns_output_format* fmt, ldns_rr_type t)
{
return fmt && (fmt->flags & LDNS_FMT_RFC3597) &&
((ldns_output_format_storage*)fmt)->bitmap &&
ldns_nsec_bitmap_covers_type(
((ldns_output_format_storage*)fmt)->bitmap, t);
}
ldns_status
ldns_output_format_set_type(ldns_output_format* fmt, ldns_rr_type t)
{
ldns_output_format_storage* fmt_st = (ldns_output_format_storage*)fmt;
ldns_status s;
assert(fmt != NULL);
if (!(fmt_st->flags & LDNS_FMT_RFC3597)) {
ldns_output_format_set(fmt, LDNS_FMT_RFC3597);
}
if (! fmt_st->bitmap) {
s = ldns_rdf_bitmap_known_rr_types_space(&fmt_st->bitmap);
if (s != LDNS_STATUS_OK) {
return s;
}
}
return ldns_nsec_bitmap_set_type(fmt_st->bitmap, t);
}
ldns_status
ldns_output_format_clear_type(ldns_output_format* fmt, ldns_rr_type t)
{
ldns_output_format_storage* fmt_st = (ldns_output_format_storage*)fmt;
ldns_status s;
assert(fmt != NULL);
if (!(fmt_st->flags & LDNS_FMT_RFC3597)) {
ldns_output_format_set(fmt, LDNS_FMT_RFC3597);
}
if (! fmt_st->bitmap) {
s = ldns_rdf_bitmap_known_rr_types(&fmt_st->bitmap);
if (s != LDNS_STATUS_OK) {
return s;
}
}
return ldns_nsec_bitmap_clear_type(fmt_st->bitmap, t);
}
ldns_status
ldns_pkt_opcode2buffer_str(ldns_buffer *output, ldns_pkt_opcode opcode)
{
ldns_lookup_table *lt = ldns_lookup_by_id(ldns_opcodes, opcode);
if (lt && lt->name) {
ldns_buffer_printf(output, "%s", lt->name);
} else {
ldns_buffer_printf(output, "OPCODE%u", opcode);
}
return ldns_buffer_status(output);
}
ldns_status
ldns_pkt_rcode2buffer_str(ldns_buffer *output, ldns_pkt_rcode rcode)
{
ldns_lookup_table *lt = ldns_lookup_by_id(ldns_rcodes, rcode);
if (lt && lt->name) {
ldns_buffer_printf(output, "%s", lt->name);
} else {
ldns_buffer_printf(output, "RCODE%u", rcode);
}
return ldns_buffer_status(output);
}
ldns_status
ldns_algorithm2buffer_str(ldns_buffer *output,
ldns_algorithm algorithm)
{
ldns_lookup_table *lt = ldns_lookup_by_id(ldns_algorithms,
algorithm);
if (lt && lt->name) {
ldns_buffer_printf(output, "%s", lt->name);
} else {
ldns_buffer_printf(output, "ALG%u", algorithm);
}
return ldns_buffer_status(output);
}
ldns_status
ldns_cert_algorithm2buffer_str(ldns_buffer *output,
ldns_cert_algorithm cert_algorithm)
{
ldns_lookup_table *lt = ldns_lookup_by_id(ldns_cert_algorithms,
cert_algorithm);
if (lt && lt->name) {
ldns_buffer_printf(output, "%s", lt->name);
} else {
ldns_buffer_printf(output, "CERT_ALG%u",
cert_algorithm);
}
return ldns_buffer_status(output);
}
char *
ldns_pkt_opcode2str(ldns_pkt_opcode opcode)
{
char *str;
ldns_buffer *buf;
buf = ldns_buffer_new(12);
if (!buf) {
return NULL;
}
str = NULL;
if (ldns_pkt_opcode2buffer_str(buf, opcode) == LDNS_STATUS_OK) {
str = ldns_buffer_export2str(buf);
}
ldns_buffer_free(buf);
return str;
}
char *
ldns_pkt_rcode2str(ldns_pkt_rcode rcode)
{
char *str;
ldns_buffer *buf;
buf = ldns_buffer_new(10);
if (!buf) {
return NULL;
}
str = NULL;
if (ldns_pkt_rcode2buffer_str(buf, rcode) == LDNS_STATUS_OK) {
str = ldns_buffer_export2str(buf);
}
ldns_buffer_free(buf);
return str;
}
char *
ldns_pkt_algorithm2str(ldns_algorithm algorithm)
{
char *str;
ldns_buffer *buf;
buf = ldns_buffer_new(10);
if (!buf) {
return NULL;
}
str = NULL;
if (ldns_algorithm2buffer_str(buf, algorithm)
== LDNS_STATUS_OK) {
str = ldns_buffer_export2str(buf);
}
ldns_buffer_free(buf);
return str;
}
char *
ldns_pkt_cert_algorithm2str(ldns_cert_algorithm cert_algorithm)
{
char *str;
ldns_buffer *buf;
buf = ldns_buffer_new(10);
if (!buf) {
return NULL;
}
str = NULL;
if (ldns_cert_algorithm2buffer_str(buf, cert_algorithm)
== LDNS_STATUS_OK) {
str = ldns_buffer_export2str(buf);
}
ldns_buffer_free(buf);
return str;
}
/* do NOT pass compressed data here :p */
ldns_status
ldns_rdf2buffer_str_dname(ldns_buffer *output, const ldns_rdf *dname)
{
/* can we do with 1 pos var? or without at all? */
uint8_t src_pos = 0;
uint8_t len;
uint8_t *data;
uint8_t i;
unsigned char c;
data = (uint8_t*)ldns_rdf_data(dname);
len = data[src_pos];
if (ldns_rdf_size(dname) > LDNS_MAX_DOMAINLEN) {
/* too large, return */
return LDNS_STATUS_DOMAINNAME_OVERFLOW;
}
/* special case: root label */
if (1 == ldns_rdf_size(dname)) {
ldns_buffer_printf(output, ".");
} else {
while ((len > 0) && src_pos < ldns_rdf_size(dname)) {
src_pos++;
for(i = 0; i < len; i++) {
/* paranoia check for various 'strange'
characters in dnames
*/
c = (unsigned char) data[src_pos];
if(c == '.' || c == ';' ||
c == '(' || c == ')' ||
c == '\\') {
ldns_buffer_printf(output, "\\%c",
data[src_pos]);
} else if (!(isascii(c) && isgraph(c))) {
ldns_buffer_printf(output, "\\%03u",
data[src_pos]);
} else {
ldns_buffer_printf(output, "%c", data[src_pos]);
}
src_pos++;
}
if (src_pos < ldns_rdf_size(dname)) {
ldns_buffer_printf(output, ".");
}
len = data[src_pos];
}
}
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_int8(ldns_buffer *output, const ldns_rdf *rdf)
{
uint8_t data = ldns_rdf_data(rdf)[0];
ldns_buffer_printf(output, "%lu", (unsigned long) data);
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_int16(ldns_buffer *output, const ldns_rdf *rdf)
{
uint16_t data = ldns_read_uint16(ldns_rdf_data(rdf));
ldns_buffer_printf(output, "%lu", (unsigned long) data);
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_int32(ldns_buffer *output, const ldns_rdf *rdf)
{
uint32_t data = ldns_read_uint32(ldns_rdf_data(rdf));
ldns_buffer_printf(output, "%lu", (unsigned long) data);
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_time(ldns_buffer *output, const ldns_rdf *rdf)
{
/* create a YYYYMMDDHHMMSS string if possible */
struct tm tm;
char date_buf[16];
memset(&tm, 0, sizeof(tm));
if (ldns_serial_arithmetics_gmtime_r(ldns_rdf2native_int32(rdf), time(NULL), &tm)
&& strftime(date_buf, 15, "%Y%m%d%H%M%S", &tm)) {
ldns_buffer_printf(output, "%s", date_buf);
}
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_a(ldns_buffer *output, const ldns_rdf *rdf)
{
char str[INET_ADDRSTRLEN];
if (inet_ntop(AF_INET, ldns_rdf_data(rdf), str, INET_ADDRSTRLEN)) {
ldns_buffer_printf(output, "%s", str);
}
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_aaaa(ldns_buffer *output, const ldns_rdf *rdf)
{
char str[INET6_ADDRSTRLEN];
if (inet_ntop(AF_INET6, ldns_rdf_data(rdf), str, INET6_ADDRSTRLEN)) {
ldns_buffer_printf(output, "%s", str);
}
return ldns_buffer_status(output);
}
static void
ldns_characters2buffer_str(ldns_buffer* output,
size_t amount, const uint8_t* characters)
{
uint8_t ch;
while (amount > 0) {
ch = *characters++;
if (isprint((int)ch) || ch == '\t') {
if (ch == '\"' || ch == '\\')
ldns_buffer_printf(output, "\\%c", ch);
else
ldns_buffer_printf(output, "%c", ch);
} else {
ldns_buffer_printf(output, "\\%03u",
(unsigned)(uint8_t) ch);
}
amount--;
}
}
ldns_status
ldns_rdf2buffer_str_str(ldns_buffer *output, const ldns_rdf *rdf)
{
if(ldns_rdf_size(rdf) < 1) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
if((int)ldns_rdf_size(rdf) < (int)ldns_rdf_data(rdf)[0] + 1) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
ldns_buffer_printf(output, "\"");
ldns_characters2buffer_str(output,
ldns_rdf_data(rdf)[0], ldns_rdf_data(rdf) + 1);
ldns_buffer_printf(output, "\"");
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_b64(ldns_buffer *output, const ldns_rdf *rdf)
{
size_t size;
char *b64;
if (ldns_rdf_size(rdf) == 0) {
ldns_buffer_printf(output, "0");
return ldns_buffer_status(output);
} else
size = ldns_b64_ntop_calculate_size(ldns_rdf_size(rdf));
if (!(b64 = LDNS_XMALLOC(char, size)))
return LDNS_STATUS_MEM_ERR;
if (ldns_b64_ntop(ldns_rdf_data(rdf), ldns_rdf_size(rdf), b64, size)) {
ldns_buffer_printf(output, "%s", b64);
}
LDNS_FREE(b64);
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_b32_ext(ldns_buffer *output, const ldns_rdf *rdf)
{
size_t size;
char *b32;
if(ldns_rdf_size(rdf) == 0)
return LDNS_STATUS_OK;
/* remove -1 for the b32-hash-len octet */
size = ldns_b32_ntop_calculate_size(ldns_rdf_size(rdf) - 1);
/* add one for the end nul for the string */
b32 = LDNS_XMALLOC(char, size + 1);
if(!b32) return LDNS_STATUS_MEM_ERR;
size = (size_t) ldns_b32_ntop_extended_hex(ldns_rdf_data(rdf) + 1,
ldns_rdf_size(rdf) - 1, b32, size+1);
if (size > 0) {
ldns_buffer_printf(output, "%s", b32);
}
LDNS_FREE(b32);
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_hex(ldns_buffer *output, const ldns_rdf *rdf)
{
size_t i;
for (i = 0; i < ldns_rdf_size(rdf); i++) {
ldns_buffer_printf(output, "%02x", ldns_rdf_data(rdf)[i]);
}
return ldns_buffer_status(output);
}
static ldns_status
ldns_rdf2buffer_str_type_fmt(ldns_buffer *output,
const ldns_output_format* fmt, const ldns_rdf *rdf)
{
uint16_t data = ldns_read_uint16(ldns_rdf_data(rdf));
if (! ldns_output_format_covers_type(fmt, data) &&
ldns_rr_descript(data) &&
ldns_rr_descript(data)->_name) {
ldns_buffer_printf(output, "%s",ldns_rr_descript(data)->_name);
} else {
ldns_buffer_printf(output, "TYPE%u", data);
}
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_type(ldns_buffer *output, const ldns_rdf *rdf)
{
return ldns_rdf2buffer_str_type_fmt(output,
ldns_output_format_default, rdf);
}
ldns_status
ldns_rdf2buffer_str_class(ldns_buffer *output, const ldns_rdf *rdf)
{
uint16_t data = ldns_read_uint16(ldns_rdf_data(rdf));
ldns_lookup_table *lt;
lt = ldns_lookup_by_id(ldns_rr_classes, (int) data);
if (lt) {
ldns_buffer_printf(output, "\t%s", lt->name);
} else {
ldns_buffer_printf(output, "\tCLASS%d", data);
}
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_cert_alg(ldns_buffer *output, const ldns_rdf *rdf)
{
uint16_t data = ldns_read_uint16(ldns_rdf_data(rdf));
ldns_lookup_table *lt;
lt = ldns_lookup_by_id(ldns_cert_algorithms, (int) data);
if (lt) {
ldns_buffer_printf(output, "%s", lt->name);
} else {
ldns_buffer_printf(output, "%d", data);
}
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_alg(ldns_buffer *output, const ldns_rdf *rdf)
{
return ldns_rdf2buffer_str_int8(output, rdf);
}
static void
loc_cm_print(ldns_buffer *output, uint8_t mantissa, uint8_t exponent)
{
uint8_t i;
/* is it 0.<two digits> ? */
if(exponent < 2) {
if(exponent == 1)
mantissa *= 10;
ldns_buffer_printf(output, "0.%02ld", (long)mantissa);
return;
}
/* always <digit><string of zeros> */
ldns_buffer_printf(output, "%d", (int)mantissa);
for(i=0; i<exponent-2; i++)
ldns_buffer_printf(output, "0");
}
ldns_status
ldns_rr_type2buffer_str(ldns_buffer *output, const ldns_rr_type type)
{
const ldns_rr_descriptor *descriptor;
descriptor = ldns_rr_descript(type);
switch (type) {
case LDNS_RR_TYPE_IXFR:
ldns_buffer_printf(output, "IXFR");
break;
case LDNS_RR_TYPE_AXFR:
ldns_buffer_printf(output, "AXFR");
break;
case LDNS_RR_TYPE_MAILA:
ldns_buffer_printf(output, "MAILA");
break;
case LDNS_RR_TYPE_MAILB:
ldns_buffer_printf(output, "MAILB");
break;
case LDNS_RR_TYPE_ANY:
ldns_buffer_printf(output, "ANY");
break;
default:
if (descriptor && descriptor->_name) {
ldns_buffer_printf(output, "%s", descriptor->_name);
} else {
ldns_buffer_printf(output, "TYPE%u", type);
}
}
return ldns_buffer_status(output);
}
char *
ldns_rr_type2str(const ldns_rr_type type)
{
char *str;
ldns_buffer *buf;
buf = ldns_buffer_new(10);
if (!buf) {
return NULL;
}
str = NULL;
if (ldns_rr_type2buffer_str(buf, type) == LDNS_STATUS_OK) {
str = ldns_buffer_export2str(buf);
}
ldns_buffer_free(buf);
return str;
}
ldns_status
ldns_rr_class2buffer_str(ldns_buffer *output,
const ldns_rr_class klass)
{
ldns_lookup_table *lt;
lt = ldns_lookup_by_id(ldns_rr_classes, klass);
if (lt) {
ldns_buffer_printf(output, "%s", lt->name);
} else {
ldns_buffer_printf(output, "CLASS%d", klass);
}
return ldns_buffer_status(output);
}
char *
ldns_rr_class2str(const ldns_rr_class klass)
{
ldns_buffer *buf;
char *str;
buf = ldns_buffer_new(10);
if (!buf) {
return NULL;
}
str = NULL;
if (ldns_rr_class2buffer_str(buf, klass) == LDNS_STATUS_OK) {
str = ldns_buffer_export2str(buf);
}
ldns_buffer_free(buf);
return str;
}
ldns_status
ldns_rdf2buffer_str_loc(ldns_buffer *output, const ldns_rdf *rdf)
{
/* we could do checking (ie degrees < 90 etc)? */
uint8_t version;
uint8_t size;
uint8_t horizontal_precision;
uint8_t vertical_precision;
uint32_t longitude;
uint32_t latitude;
uint32_t altitude;
char latitude_hemisphere;
char longitude_hemisphere;
uint32_t h;
uint32_t m;
double s;
uint32_t equator = (uint32_t) ldns_power(2, 31);
if(ldns_rdf_size(rdf) < 1) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
version = ldns_rdf_data(rdf)[0];
if (version == 0) {
if(ldns_rdf_size(rdf) < 16) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
size = ldns_rdf_data(rdf)[1];
horizontal_precision = ldns_rdf_data(rdf)[2];
vertical_precision = ldns_rdf_data(rdf)[3];
latitude = ldns_read_uint32(&ldns_rdf_data(rdf)[4]);
longitude = ldns_read_uint32(&ldns_rdf_data(rdf)[8]);
altitude = ldns_read_uint32(&ldns_rdf_data(rdf)[12]);
if (latitude > equator) {
latitude_hemisphere = 'N';
latitude = latitude - equator;
} else {
latitude_hemisphere = 'S';
latitude = equator - latitude;
}
h = latitude / (1000 * 60 * 60);
latitude = latitude % (1000 * 60 * 60);
m = latitude / (1000 * 60);
latitude = latitude % (1000 * 60);
s = (double) latitude / 1000.0;
ldns_buffer_printf(output, "%02u %02u %0.3f %c ",
h, m, s, latitude_hemisphere);
if (longitude > equator) {
longitude_hemisphere = 'E';
longitude = longitude - equator;
} else {
longitude_hemisphere = 'W';
longitude = equator - longitude;
}
h = longitude / (1000 * 60 * 60);
longitude = longitude % (1000 * 60 * 60);
m = longitude / (1000 * 60);
longitude = longitude % (1000 * 60);
s = (double) longitude / (1000.0);
ldns_buffer_printf(output, "%02u %02u %0.3f %c ",
h, m, s, longitude_hemisphere);
s = ((double) altitude) / 100;
s -= 100000;
if(altitude%100 != 0)
ldns_buffer_printf(output, "%.2f", s);
else
ldns_buffer_printf(output, "%.0f", s);
ldns_buffer_printf(output, "m ");
loc_cm_print(output, (size & 0xf0) >> 4, size & 0x0f);
ldns_buffer_printf(output, "m ");
loc_cm_print(output, (horizontal_precision & 0xf0) >> 4,
horizontal_precision & 0x0f);
ldns_buffer_printf(output, "m ");
loc_cm_print(output, (vertical_precision & 0xf0) >> 4,
vertical_precision & 0x0f);
ldns_buffer_printf(output, "m");
return ldns_buffer_status(output);
} else {
return ldns_rdf2buffer_str_hex(output, rdf);
}
}
ldns_status
ldns_rdf2buffer_str_unknown(ldns_buffer *output, const ldns_rdf *rdf)
{
ldns_buffer_printf(output, "\\# %u ", ldns_rdf_size(rdf));
return ldns_rdf2buffer_str_hex(output, rdf);
}
ldns_status
ldns_rdf2buffer_str_nsap(ldns_buffer *output, const ldns_rdf *rdf)
{
ldns_buffer_printf(output, "0x");
return ldns_rdf2buffer_str_hex(output, rdf);
}
ldns_status
ldns_rdf2buffer_str_atma(ldns_buffer *output, const ldns_rdf *rdf)
{
return ldns_rdf2buffer_str_hex(output, rdf);
}
ldns_status
ldns_rdf2buffer_str_wks(ldns_buffer *output, const ldns_rdf *rdf)
{
/* protocol, followed by bitmap of services */
struct protoent *protocol;
char *proto_name = NULL;
uint8_t protocol_nr;
struct servent *service;
uint16_t current_service;
if(ldns_rdf_size(rdf) < 1) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
protocol_nr = ldns_rdf_data(rdf)[0];
protocol = getprotobynumber((int) protocol_nr);
if (protocol && (protocol->p_name != NULL)) {
proto_name = protocol->p_name;
ldns_buffer_printf(output, "%s ", protocol->p_name);
} else {
ldns_buffer_printf(output, "%u ", protocol_nr);
}
for (current_service = 0;
current_service < (ldns_rdf_size(rdf)-1)*8; current_service++) {
if (ldns_get_bit(&(ldns_rdf_data(rdf)[1]), current_service)) {
service = getservbyport((int) htons(current_service),
proto_name);
if (service && service->s_name) {
ldns_buffer_printf(output, "%s ", service->s_name);
} else {
ldns_buffer_printf(output, "%u ", current_service);
}
#ifdef HAVE_ENDSERVENT
endservent();
#endif
}
/* exit from loop before integer overflow */
if(current_service == 65535) { break; }
}
#ifdef HAVE_ENDPROTOENT
endprotoent();
#endif
return ldns_buffer_status(output);
}
static ldns_status
ldns_rdf2buffer_str_nsec_fmt(ldns_buffer *output,
const ldns_output_format* fmt, const ldns_rdf *rdf)
{
/* Note: this code is duplicated in higher.c in
* ldns_nsec_type_check() function
*/
uint8_t window_block_nr;
uint8_t bitmap_length;
uint16_t type;
uint16_t pos = 0;
uint16_t bit_pos;
uint8_t *data = ldns_rdf_data(rdf);
while((size_t)(pos + 2) < ldns_rdf_size(rdf)) {
window_block_nr = data[pos];
bitmap_length = data[pos + 1];
pos += 2;
if (ldns_rdf_size(rdf) < pos + bitmap_length) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
for (bit_pos = 0; bit_pos < (bitmap_length) * 8; bit_pos++) {
if (! ldns_get_bit(&data[pos], bit_pos)) {
continue;
}
type = 256 * (uint16_t) window_block_nr + bit_pos;
if (! ldns_output_format_covers_type(fmt, type) &&
ldns_rr_descript(type) &&
ldns_rr_descript(type)->_name){
ldns_buffer_printf(output, "%s ",
ldns_rr_descript(type)->_name);
} else {
ldns_buffer_printf(output, "TYPE%u ", type);
}
}
pos += (uint16_t) bitmap_length;
}
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_nsec(ldns_buffer *output, const ldns_rdf *rdf)
{
return ldns_rdf2buffer_str_nsec_fmt(output,
ldns_output_format_default, rdf);
}
ldns_status
ldns_rdf2buffer_str_nsec3_salt(ldns_buffer *output, const ldns_rdf *rdf)
{
uint8_t salt_length;
uint8_t salt_pos;
uint8_t *data = ldns_rdf_data(rdf);
if(ldns_rdf_size(rdf) < 1) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
salt_length = data[0];
/* from now there are variable length entries so remember pos */
if (salt_length == 0 || ((size_t)salt_length)+1 > ldns_rdf_size(rdf)) {
ldns_buffer_printf(output, "- ");
} else {
for (salt_pos = 0; salt_pos < salt_length; salt_pos++) {
ldns_buffer_printf(output, "%02x", data[1 + salt_pos]);
}
ldns_buffer_printf(output, " ");
}
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_period(ldns_buffer *output, const ldns_rdf *rdf)
{
/* period is the number of seconds */
if (ldns_rdf_size(rdf) != 4) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
ldns_buffer_printf(output, "%u", ldns_read_uint32(ldns_rdf_data(rdf)));
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_tsigtime(ldns_buffer *output,const ldns_rdf *rdf)
{
/* tsigtime is 48 bits network order unsigned integer */
uint64_t tsigtime = 0;
uint8_t *data = ldns_rdf_data(rdf);
uint64_t d0, d1, d2, d3, d4, d5;
if (ldns_rdf_size(rdf) < 6) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
d0 = data[0]; /* cast to uint64 for shift operations */
d1 = data[1];
d2 = data[2];
d3 = data[3];
d4 = data[4];
d5 = data[5];
tsigtime = (d0<<40) | (d1<<32) | (d2<<24) | (d3<<16) | (d4<<8) | d5;
ldns_buffer_printf(output, "%llu ", (long long)tsigtime);
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_apl(ldns_buffer *output, const ldns_rdf *rdf)
{
uint8_t *data = ldns_rdf_data(rdf);
uint16_t address_family;
uint8_t prefix;
bool negation;
uint8_t adf_length;
size_t i;
size_t pos = 0;
while (pos < (unsigned int) ldns_rdf_size(rdf)) {
if(pos + 3 >= (unsigned)ldns_rdf_size(rdf))
return LDNS_STATUS_WIRE_RDATA_ERR;
address_family = ldns_read_uint16(&data[pos]);
prefix = data[pos + 2];
negation = data[pos + 3] & LDNS_APL_NEGATION;
adf_length = data[pos + 3] & LDNS_APL_MASK;
if (address_family == LDNS_APL_IP4) {
/* check if prefix < 32? */
if (negation) {
ldns_buffer_printf(output, "!");
}
ldns_buffer_printf(output, "%u:", address_family);
/* address is variable length 0 - 4 */
for (i = 0; i < 4; i++) {
if (i > 0) {
ldns_buffer_printf(output, ".");
}
if (i < (unsigned short) adf_length) {
if(pos+i+4 >= ldns_rdf_size(rdf))
return LDNS_STATUS_WIRE_RDATA_ERR;
ldns_buffer_printf(output, "%d",
data[pos + i + 4]);
} else {
ldns_buffer_printf(output, "0");
}
}
ldns_buffer_printf(output, "/%u ", prefix);
} else if (address_family == LDNS_APL_IP6) {
/* check if prefix < 128? */
if (negation) {
ldns_buffer_printf(output, "!");
}
ldns_buffer_printf(output, "%u:", address_family);
/* address is variable length 0 - 16 */
for (i = 0; i < 16; i++) {
if (i % 2 == 0 && i > 0) {
ldns_buffer_printf(output, ":");
}
if (i < (unsigned short) adf_length) {
if(pos+i+4 >= ldns_rdf_size(rdf))
return LDNS_STATUS_WIRE_RDATA_ERR;
ldns_buffer_printf(output, "%02x",
data[pos + i + 4]);
} else {
ldns_buffer_printf(output, "00");
}
}
ldns_buffer_printf(output, "/%u ", prefix);
} else {
/* unknown address family */
ldns_buffer_printf(output,
"Unknown address family: %u data: ",
address_family);
for (i = 1; i < (unsigned short) (4 + adf_length); i++) {
if(pos+i >= ldns_rdf_size(rdf))
return LDNS_STATUS_WIRE_RDATA_ERR;
ldns_buffer_printf(output, "%02x", data[i]);
}
}
pos += 4 + adf_length;
}
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_int16_data(ldns_buffer *output, const ldns_rdf *rdf)
{
size_t size;
char *b64;
if (ldns_rdf_size(rdf) < 2) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
/* Subtract the size (2) of the number that specifies the length */
size = ldns_b64_ntop_calculate_size(ldns_rdf_size(rdf) - 2);
ldns_buffer_printf(output, "%u ", ldns_rdf_size(rdf) - 2);
if (ldns_rdf_size(rdf) > 2) {
b64 = LDNS_XMALLOC(char, size);
if(!b64)
return LDNS_STATUS_MEM_ERR;
if (ldns_rdf_size(rdf) > 2 &&
ldns_b64_ntop(ldns_rdf_data(rdf) + 2,
ldns_rdf_size(rdf) - 2,
b64, size)) {
ldns_buffer_printf(output, "%s", b64);
}
LDNS_FREE(b64);
}
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf)
{
/* wire format from
http://www.ietf.org/internet-drafts/draft-ietf-ipseckey-rr-12.txt
*/
uint8_t *data = ldns_rdf_data(rdf);
uint8_t precedence;
uint8_t gateway_type;
uint8_t algorithm;
ldns_rdf *gateway = NULL;
uint8_t *gateway_data;
size_t public_key_size;
uint8_t *public_key_data;
ldns_rdf *public_key;
size_t offset = 0;
ldns_status status;
if (ldns_rdf_size(rdf) < 3) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
precedence = data[0];
gateway_type = data[1];
algorithm = data[2];
offset = 3;
switch (gateway_type) {
case 0:
/* no gateway */
break;
case 1:
if (ldns_rdf_size(rdf) < offset + LDNS_IP4ADDRLEN) {
return LDNS_STATUS_ERR;
}
gateway_data = LDNS_XMALLOC(uint8_t, LDNS_IP4ADDRLEN);
if(!gateway_data)
return LDNS_STATUS_MEM_ERR;
memcpy(gateway_data, &data[offset], LDNS_IP4ADDRLEN);
gateway = ldns_rdf_new(LDNS_RDF_TYPE_A,
LDNS_IP4ADDRLEN , gateway_data);
offset += LDNS_IP4ADDRLEN;
if(!gateway) {
LDNS_FREE(gateway_data);
return LDNS_STATUS_MEM_ERR;
}
break;
case 2:
if (ldns_rdf_size(rdf) < offset + LDNS_IP6ADDRLEN) {
return LDNS_STATUS_ERR;
}
gateway_data = LDNS_XMALLOC(uint8_t, LDNS_IP6ADDRLEN);
if(!gateway_data)
return LDNS_STATUS_MEM_ERR;
memcpy(gateway_data, &data[offset], LDNS_IP6ADDRLEN);
offset += LDNS_IP6ADDRLEN;
gateway =
ldns_rdf_new(LDNS_RDF_TYPE_AAAA,
LDNS_IP6ADDRLEN, gateway_data);
if(!gateway) {
LDNS_FREE(gateway_data);
return LDNS_STATUS_MEM_ERR;
}
break;
case 3:
status = ldns_wire2dname(&gateway, data,
ldns_rdf_size(rdf), &offset);
if(status != LDNS_STATUS_OK)
return status;
break;
default:
/* error? */
break;
}
if (ldns_rdf_size(rdf) <= offset) {
ldns_rdf_deep_free(gateway);
return LDNS_STATUS_ERR;
}
public_key_size = ldns_rdf_size(rdf) - offset;
public_key_data = LDNS_XMALLOC(uint8_t, public_key_size);
if(!public_key_data) {
ldns_rdf_deep_free(gateway);
return LDNS_STATUS_MEM_ERR;
}
memcpy(public_key_data, &data[offset], public_key_size);
public_key = ldns_rdf_new(LDNS_RDF_TYPE_B64,
public_key_size, public_key_data);
if(!public_key) {
LDNS_FREE(public_key_data);
ldns_rdf_deep_free(gateway);
return LDNS_STATUS_MEM_ERR;
}
ldns_buffer_printf(output, "%u %u %u ", precedence, gateway_type, algorithm);
if (gateway)
(void) ldns_rdf2buffer_str(output, gateway);
else
ldns_buffer_printf(output, ".");
ldns_buffer_printf(output, " ");
(void) ldns_rdf2buffer_str(output, public_key);
ldns_rdf_deep_free(gateway);
ldns_rdf_deep_free(public_key);
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_ilnp64(ldns_buffer *output, const ldns_rdf *rdf)
{
if (ldns_rdf_size(rdf) != 8) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
ldns_buffer_printf(output,"%.4x:%.4x:%.4x:%.4x",
ldns_read_uint16(ldns_rdf_data(rdf)),
ldns_read_uint16(ldns_rdf_data(rdf)+2),
ldns_read_uint16(ldns_rdf_data(rdf)+4),
ldns_read_uint16(ldns_rdf_data(rdf)+6));
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_eui48(ldns_buffer *output, const ldns_rdf *rdf)
{
if (ldns_rdf_size(rdf) != 6) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
ldns_buffer_printf(output,"%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
ldns_rdf_data(rdf)[0], ldns_rdf_data(rdf)[1],
ldns_rdf_data(rdf)[2], ldns_rdf_data(rdf)[3],
ldns_rdf_data(rdf)[4], ldns_rdf_data(rdf)[5]);
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_eui64(ldns_buffer *output, const ldns_rdf *rdf)
{
if (ldns_rdf_size(rdf) != 8) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
ldns_buffer_printf(output,"%.2x-%.2x-%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
ldns_rdf_data(rdf)[0], ldns_rdf_data(rdf)[1],
ldns_rdf_data(rdf)[2], ldns_rdf_data(rdf)[3],
ldns_rdf_data(rdf)[4], ldns_rdf_data(rdf)[5],
ldns_rdf_data(rdf)[6], ldns_rdf_data(rdf)[7]);
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_tag(ldns_buffer *output, const ldns_rdf *rdf)
{
size_t nchars;
const uint8_t* chars;
char ch;
if (ldns_rdf_size(rdf) < 2) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
nchars = ldns_rdf_data(rdf)[0];
if (nchars >= ldns_rdf_size(rdf) || /* should be rdf_size - 1 */
nchars < 1) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
chars = ldns_rdf_data(rdf) + 1;
while (nchars > 0) {
ch = (char)*chars++;
if (! isalnum((unsigned char)ch)) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
ldns_buffer_printf(output, "%c", ch);
nchars--;
}
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_long_str(ldns_buffer *output, const ldns_rdf *rdf)
{
ldns_buffer_printf(output, "\"");
ldns_characters2buffer_str(output,
ldns_rdf_size(rdf), ldns_rdf_data(rdf));
ldns_buffer_printf(output, "\"");
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_hip(ldns_buffer *output, const ldns_rdf *rdf)
{
uint8_t *data = ldns_rdf_data(rdf);
size_t rdf_size = ldns_rdf_size(rdf);
uint8_t hit_size;
uint16_t pk_size;
int written;
if (rdf_size < 6) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
if ((hit_size = data[0]) == 0 ||
(pk_size = ldns_read_uint16(data + 2)) == 0 ||
rdf_size < (size_t) hit_size + pk_size + 4) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
ldns_buffer_printf(output, "%d ", (int) data[1]);
for (data += 4; hit_size > 0; hit_size--, data++) {
ldns_buffer_printf(output, "%02x", (int) *data);
}
ldns_buffer_write_char(output, (uint8_t) ' ');
if (ldns_buffer_reserve(output,
ldns_b64_ntop_calculate_size(pk_size))) {
written = ldns_b64_ntop(data, pk_size,
(char *) ldns_buffer_current(output),
ldns_buffer_remaining(output));
if (written > 0 &&
written < (int) ldns_buffer_remaining(output)) {
output->_position += written;
}
}
return ldns_buffer_status(output);
}
/* implementation mimicked from ldns_rdf2buffer_str_ipseckey */
ldns_status
ldns_rdf2buffer_str_amtrelay(ldns_buffer *output, const ldns_rdf *rdf)
{
/* wire format from
* draft-ietf-mboned-driad-amt-discovery Section 4.2
*/
uint8_t *data = ldns_rdf_data(rdf);
uint8_t precedence;
uint8_t discovery_optional;
uint8_t relay_type;
ldns_rdf *relay = NULL;
uint8_t *relay_data;
size_t offset = 0;
ldns_status status;
if (ldns_rdf_size(rdf) < 2) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
precedence = data[0];
discovery_optional = ((data[1] & 0x80) >> 7);
relay_type = data[1] & 0x7F;
offset = 2;
switch (relay_type) {
case 0:
/* no relay */
break;
case 1:
if (ldns_rdf_size(rdf) < offset + LDNS_IP4ADDRLEN) {
return LDNS_STATUS_ERR;
}
relay_data = LDNS_XMALLOC(uint8_t, LDNS_IP4ADDRLEN);
if(!relay_data)
return LDNS_STATUS_MEM_ERR;
memcpy(relay_data, &data[offset], LDNS_IP4ADDRLEN);
relay = ldns_rdf_new(LDNS_RDF_TYPE_A,
LDNS_IP4ADDRLEN , relay_data);
offset += LDNS_IP4ADDRLEN;
if(!relay) {
LDNS_FREE(relay_data);
return LDNS_STATUS_MEM_ERR;
}
break;
case 2:
if (ldns_rdf_size(rdf) < offset + LDNS_IP6ADDRLEN) {
return LDNS_STATUS_ERR;
}
relay_data = LDNS_XMALLOC(uint8_t, LDNS_IP6ADDRLEN);
if(!relay_data)
return LDNS_STATUS_MEM_ERR;
memcpy(relay_data, &data[offset], LDNS_IP6ADDRLEN);
offset += LDNS_IP6ADDRLEN;
relay =
ldns_rdf_new(LDNS_RDF_TYPE_AAAA,
LDNS_IP6ADDRLEN, relay_data);
if(!relay) {
LDNS_FREE(relay_data);
return LDNS_STATUS_MEM_ERR;
}
break;
case 3:
status = ldns_wire2dname(&relay, data,
ldns_rdf_size(rdf), &offset);
if(status != LDNS_STATUS_OK)
return status;
break;
default:
/* error? */
break;
}
if (ldns_rdf_size(rdf) != offset) {
ldns_rdf_deep_free(relay);
return LDNS_STATUS_ERR;
}
ldns_buffer_printf(output, "%u %u %u ",
precedence, discovery_optional, relay_type);
if (relay)
(void) ldns_rdf2buffer_str(output, relay);
ldns_rdf_deep_free(relay);
return ldns_buffer_status(output);
}
#ifdef RRTYPE_SVCB_HTTPS
ldns_status svcparam_key2buffer_str(ldns_buffer *output, uint16_t key);
static ldns_status
svcparam_mandatory2buffer_str(ldns_buffer *output, size_t sz, uint8_t *data)
{
if (sz % 2)
return LDNS_STATUS_INVALID_SVCPARAM_VALUE;
svcparam_key2buffer_str(output, ldns_read_uint16(data));
for (data += 2, sz -= 2; sz; data += 2, sz -= 2) {
ldns_buffer_write_char(output, ',');
svcparam_key2buffer_str(output, ldns_read_uint16(data));
}
return ldns_buffer_status(output);
}
static ldns_status
svcparam_alpn2buffer_str(ldns_buffer *output, size_t sz, uint8_t *data)
{
uint8_t *eod = data + sz, *dp;
bool quote = false;
size_t i;
for (dp = data; dp < eod && !quote; dp += 1 + *dp) {
if (dp + 1 + *dp > eod)
return LDNS_STATUS_INVALID_SVCPARAM_VALUE;
for (i = 0; i < *dp; i++)
if (isspace(dp[i + 1]))
break;
quote = i < *dp;
}
if (quote)
ldns_buffer_write_char(output, '"');
while (data < eod) {
uint8_t *eot = data + 1 + *data;
if (eot > eod)
return LDNS_STATUS_INVALID_SVCPARAM_VALUE;
if (eod - data < (int)sz)
ldns_buffer_write_char(output, ',');
for (data += 1; data < eot; data += 1) {
uint8_t ch = *data;
if (isprint(ch) || ch == '\t') {
if (ch == '"' || ch == ',' || ch == '\\')
ldns_buffer_write_char(output, '\\');
ldns_buffer_write_char(output, ch);
} else
ldns_buffer_printf(output, "\\%03u"
, (unsigned)ch);
}
}
if (quote)
ldns_buffer_write_char(output, '"');
return ldns_buffer_status(output);
}
static ldns_status
svcparam_port2buffer_str(ldns_buffer *output, size_t sz, uint8_t *data)
{
if (sz != 2)
return LDNS_STATUS_INVALID_SVCPARAM_VALUE;
ldns_buffer_printf(output, "%d", (int)ldns_read_uint16(data));
return ldns_buffer_status(output);
}
static ldns_status
svcparam_ipv4hint2buffer_str(ldns_buffer *output, size_t sz, uint8_t *data)
{
char str[INET_ADDRSTRLEN];
if (sz % 4 || !inet_ntop(AF_INET, data, str, INET_ADDRSTRLEN))
return LDNS_STATUS_INVALID_SVCPARAM_VALUE;
ldns_buffer_write_chars(output, str);
for (data += 4, sz -= 4; sz ; data += 4, sz -= 4 ) {
ldns_buffer_write_char(output, ',');
if (!inet_ntop(AF_INET, data, str, INET_ADDRSTRLEN))
return LDNS_STATUS_INVALID_SVCPARAM_VALUE;
ldns_buffer_write_chars(output, str);
}
return ldns_buffer_status(output);
}
static ldns_status
svcparam_ech2buffer_str(ldns_buffer *output, size_t sz, uint8_t *data)
{
size_t str_sz = ldns_b64_ntop_calculate_size(sz);
int written;
if (!ldns_buffer_reserve(output, str_sz))
return LDNS_STATUS_MEM_ERR;
written = ldns_b64_ntop( data, sz
, (char *)ldns_buffer_current(output), str_sz);
if (written > 0)
ldns_buffer_skip(output, written);
else
return LDNS_STATUS_INVALID_SVCPARAM_VALUE;
return ldns_buffer_status(output);
}
static ldns_status
svcparam_ipv6hint2buffer_str(ldns_buffer *output, size_t sz, uint8_t *data)
{
char str[INET6_ADDRSTRLEN];
if (sz % 16 || !inet_ntop(AF_INET6, data, str, INET6_ADDRSTRLEN))
return LDNS_STATUS_INVALID_SVCPARAM_VALUE;
ldns_buffer_write_chars(output, str);
for (data += 16, sz -= 16; sz ; data += 16, sz -= 16) {
ldns_buffer_write_char(output, ',');
if (!inet_ntop(AF_INET6, data, str, INET6_ADDRSTRLEN))
return LDNS_STATUS_INVALID_SVCPARAM_VALUE;
ldns_buffer_write_chars(output, str);
}
return ldns_buffer_status(output);
}
static ldns_status
svcparam_value2buffer_str(ldns_buffer *output, size_t sz, uint8_t *data)
{
uint8_t *eod = data + sz, *dp;
bool quote = false;
for (dp = data; dp < eod && !isspace(*dp); dp++)
; /* pass */
if ((quote = dp < eod))
ldns_buffer_write_char(output, '"');
for (dp = data; dp < eod; dp++) {
uint8_t ch = *dp;
if (isprint(ch) || ch == '\t') {
if (ch == '"' || ch == '\\')
ldns_buffer_write_char(output, '\\');
ldns_buffer_write_char(output, ch);
} else
ldns_buffer_printf(output, "\\%03u", (unsigned)ch);
}
if (quote)
ldns_buffer_write_char(output, '"');
return ldns_buffer_status(output);
}
ldns_status
ldns_rdf2buffer_str_svcparams(ldns_buffer *output, const ldns_rdf *rdf)
{
uint8_t *data, *dp, *next_dp = NULL;
size_t sz;
ldns_status st;
if (!output)
return LDNS_STATUS_NULL;
if (!rdf || !(data = ldns_rdf_data(rdf)) || !(sz = ldns_rdf_size(rdf)))
/* No svcparams is just fine. Just nothing to print. */
return LDNS_STATUS_OK;
for (dp = data; dp + 4 <= data + sz; dp = next_dp) {
ldns_svcparam_key key = ldns_read_uint16(dp);
uint16_t val_sz = ldns_read_uint16(dp + 2);
if ((next_dp = dp + 4 + val_sz) > data + sz)
return LDNS_STATUS_RDATA_OVERFLOW;
if (dp > data)
ldns_buffer_write_char(output, ' ');
if ((st = svcparam_key2buffer_str(output, key)))
return st;
if (val_sz == 0)
continue;
dp += 4;
ldns_buffer_write_char(output, '=');
switch (key) {
case LDNS_SVCPARAM_KEY_MANDATORY:
st = svcparam_mandatory2buffer_str(output, val_sz, dp);
break;
case LDNS_SVCPARAM_KEY_ALPN:
st = svcparam_alpn2buffer_str(output, val_sz, dp);
break;
case LDNS_SVCPARAM_KEY_NO_DEFAULT_ALPN:
return LDNS_STATUS_NO_SVCPARAM_VALUE_EXPECTED;
case LDNS_SVCPARAM_KEY_PORT:
st = svcparam_port2buffer_str(output, val_sz, dp);
break;
case LDNS_SVCPARAM_KEY_IPV4HINT:
st = svcparam_ipv4hint2buffer_str(output, val_sz, dp);
break;
case LDNS_SVCPARAM_KEY_ECH:
st = svcparam_ech2buffer_str(output, val_sz, dp);
break;
case LDNS_SVCPARAM_KEY_IPV6HINT:
st = svcparam_ipv6hint2buffer_str(output, val_sz, dp);
break;
default:
st = svcparam_value2buffer_str(output, val_sz, dp);
break;
}
if (st)
return st;
}
return ldns_buffer_status(output);
}
#else /* #ifdef RRTYPE_SVCB_HTTPS */
ldns_status
ldns_rdf2buffer_str_svcparams(ldns_buffer *output, const ldns_rdf *rdf)
{
(void)output; (void)rdf;
return LDNS_STATUS_NOT_IMPL;
}
#endif /* #ifdef RRTYPE_SVCB_HTTPS */
static ldns_status
ldns_rdf2buffer_str_fmt(ldns_buffer *buffer,
const ldns_output_format* fmt, const ldns_rdf *rdf)
{
ldns_status res = LDNS_STATUS_OK;
/*ldns_buffer_printf(buffer, "%u:", ldns_rdf_get_type(rdf));*/
if (rdf) {
switch(ldns_rdf_get_type(rdf)) {
case LDNS_RDF_TYPE_NONE:
break;
case LDNS_RDF_TYPE_DNAME:
res = ldns_rdf2buffer_str_dname(buffer, rdf);
break;
case LDNS_RDF_TYPE_INT8: /* Don't output mnemonics for these */
case LDNS_RDF_TYPE_ALG:
case LDNS_RDF_TYPE_CERTIFICATE_USAGE:
case LDNS_RDF_TYPE_SELECTOR:
case LDNS_RDF_TYPE_MATCHING_TYPE:
res = ldns_rdf2buffer_str_int8(buffer, rdf);
break;
case LDNS_RDF_TYPE_INT16:
res = ldns_rdf2buffer_str_int16(buffer, rdf);
break;
case LDNS_RDF_TYPE_INT32:
res = ldns_rdf2buffer_str_int32(buffer, rdf);
break;
case LDNS_RDF_TYPE_PERIOD:
res = ldns_rdf2buffer_str_period(buffer, rdf);
break;
case LDNS_RDF_TYPE_TSIGTIME:
res = ldns_rdf2buffer_str_tsigtime(buffer, rdf);
break;
case LDNS_RDF_TYPE_A:
res = ldns_rdf2buffer_str_a(buffer, rdf);
break;
case LDNS_RDF_TYPE_AAAA:
res = ldns_rdf2buffer_str_aaaa(buffer, rdf);
break;
case LDNS_RDF_TYPE_STR:
res = ldns_rdf2buffer_str_str(buffer, rdf);
break;
case LDNS_RDF_TYPE_APL:
res = ldns_rdf2buffer_str_apl(buffer, rdf);
break;
case LDNS_RDF_TYPE_B32_EXT:
res = ldns_rdf2buffer_str_b32_ext(buffer, rdf);
break;
case LDNS_RDF_TYPE_B64:
res = ldns_rdf2buffer_str_b64(buffer, rdf);
break;
case LDNS_RDF_TYPE_HEX:
res = ldns_rdf2buffer_str_hex(buffer, rdf);
break;
case LDNS_RDF_TYPE_NSEC:
res = ldns_rdf2buffer_str_nsec_fmt(buffer, fmt, rdf);
break;
case LDNS_RDF_TYPE_NSEC3_SALT:
res = ldns_rdf2buffer_str_nsec3_salt(buffer, rdf);
break;
case LDNS_RDF_TYPE_TYPE:
res = ldns_rdf2buffer_str_type_fmt(buffer, fmt, rdf);
break;
case LDNS_RDF_TYPE_CLASS:
res = ldns_rdf2buffer_str_class(buffer, rdf);
break;
case LDNS_RDF_TYPE_CERT_ALG:
res = ldns_rdf2buffer_str_cert_alg(buffer, rdf);
break;
case LDNS_RDF_TYPE_UNKNOWN:
res = ldns_rdf2buffer_str_unknown(buffer, rdf);
break;
case LDNS_RDF_TYPE_TIME:
res = ldns_rdf2buffer_str_time(buffer, rdf);
break;
case LDNS_RDF_TYPE_HIP:
res = ldns_rdf2buffer_str_hip(buffer, rdf);
break;
case LDNS_RDF_TYPE_LOC:
res = ldns_rdf2buffer_str_loc(buffer, rdf);
break;
case LDNS_RDF_TYPE_WKS:
case LDNS_RDF_TYPE_SERVICE:
res = ldns_rdf2buffer_str_wks(buffer, rdf);
break;
case LDNS_RDF_TYPE_NSAP:
res = ldns_rdf2buffer_str_nsap(buffer, rdf);
break;
case LDNS_RDF_TYPE_ATMA:
res = ldns_rdf2buffer_str_atma(buffer, rdf);
break;
case LDNS_RDF_TYPE_IPSECKEY:
res = ldns_rdf2buffer_str_ipseckey(buffer, rdf);
break;
case LDNS_RDF_TYPE_INT16_DATA:
res = ldns_rdf2buffer_str_int16_data(buffer, rdf);
break;
case LDNS_RDF_TYPE_NSEC3_NEXT_OWNER:
res = ldns_rdf2buffer_str_b32_ext(buffer, rdf);
break;
case LDNS_RDF_TYPE_ILNP64:
res = ldns_rdf2buffer_str_ilnp64(buffer, rdf);
break;
case LDNS_RDF_TYPE_EUI48:
res = ldns_rdf2buffer_str_eui48(buffer, rdf);
break;
case LDNS_RDF_TYPE_EUI64:
res = ldns_rdf2buffer_str_eui64(buffer, rdf);
break;
case LDNS_RDF_TYPE_TAG:
res = ldns_rdf2buffer_str_tag(buffer, rdf);
break;
case LDNS_RDF_TYPE_LONG_STR:
res = ldns_rdf2buffer_str_long_str(buffer, rdf);
break;
case LDNS_RDF_TYPE_AMTRELAY:
res = ldns_rdf2buffer_str_amtrelay(buffer, rdf);
break;
case LDNS_RDF_TYPE_SVCPARAMS:
res = ldns_rdf2buffer_str_svcparams(buffer, rdf);
break;
}
} else {
ldns_buffer_printf(buffer, "(null) ");
res = LDNS_STATUS_ERR;
}
return res;
}
ldns_status
ldns_rdf2buffer_str(ldns_buffer *buffer, const ldns_rdf *rdf)
{
return ldns_rdf2buffer_str_fmt(buffer,ldns_output_format_default,rdf);
}
static ldns_rdf *
ldns_b32_ext2dname(const ldns_rdf *rdf)
{
size_t size;
char *b32;
ldns_rdf *out;
if(ldns_rdf_size(rdf) == 0)
return NULL;
/* remove -1 for the b32-hash-len octet */
size = ldns_b32_ntop_calculate_size(ldns_rdf_size(rdf) - 1);
/* add one for the end nul for the string */
b32 = LDNS_XMALLOC(char, size + 2);
if (b32) {
if (ldns_b32_ntop_extended_hex(ldns_rdf_data(rdf) + 1,
ldns_rdf_size(rdf) - 1, b32, size+1) > 0) {
b32[size] = '.';
b32[size+1] = '\0';
if (ldns_str2rdf_dname(&out, b32) == LDNS_STATUS_OK) {
LDNS_FREE(b32);
return out;
}
}
LDNS_FREE(b32);
}
return NULL;
}
static ldns_status
ldns_rr2buffer_str_rfc3597(ldns_buffer *output, const ldns_rr *rr)
{
size_t total_rdfsize = 0;
size_t i, j;
ldns_buffer_printf(output, "TYPE%u\t", ldns_rr_get_type(rr));
for (i = 0; i < ldns_rr_rd_count(rr); i++) {
total_rdfsize += ldns_rdf_size(ldns_rr_rdf(rr, i));
}
if (total_rdfsize == 0) {
ldns_buffer_printf(output, "\\# 0\n");
return ldns_buffer_status(output);
}
ldns_buffer_printf(output, "\\# %d ", total_rdfsize);
for (i = 0; i < ldns_rr_rd_count(rr); i++) {
for (j = 0; j < ldns_rdf_size(ldns_rr_rdf(rr, i)); j++) {
ldns_buffer_printf(output, "%.2x",
ldns_rdf_data(ldns_rr_rdf(rr, i))[j]);
}
}
ldns_buffer_printf(output, "\n");
return ldns_buffer_status(output);
}
ldns_status
ldns_rr2buffer_str_fmt(ldns_buffer *output,
const ldns_output_format *fmt, const ldns_rr *rr)
{
uint16_t i, flags;
ldns_status status = LDNS_STATUS_OK;
ldns_output_format_storage* fmt_st = (ldns_output_format_storage*)fmt;
if (fmt_st == NULL) {
fmt_st = (ldns_output_format_storage*)
ldns_output_format_default;
}
if (!(fmt_st->flags & LDNS_FMT_SHORT)) {
if (!rr) {
if (LDNS_COMMENT_NULLS & fmt_st->flags) {
ldns_buffer_printf(output, "; (null)\n");
}
return ldns_buffer_status(output);
}
if (ldns_rr_owner(rr)) {
status = ldns_rdf2buffer_str_dname(output, ldns_rr_owner(rr));
}
if (status != LDNS_STATUS_OK) {
return status;
}
/* TTL should NOT be printed if it is a question */
if (!ldns_rr_is_question(rr)) {
ldns_buffer_printf(output, "\t%u", (unsigned)ldns_rr_ttl(rr));
}
ldns_buffer_printf(output, "\t");
status = ldns_rr_class2buffer_str(output, ldns_rr_get_class(rr));
if (status != LDNS_STATUS_OK) {
return status;
}
ldns_buffer_printf(output, "\t");
if (ldns_output_format_covers_type(fmt, ldns_rr_get_type(rr))) {
return ldns_rr2buffer_str_rfc3597(output, rr);
}
status = ldns_rr_type2buffer_str(output, ldns_rr_get_type(rr));
if (status != LDNS_STATUS_OK) {
return status;
}
if (ldns_rr_rd_count(rr) > 0) {
ldns_buffer_printf(output, "\t");
} else if (!ldns_rr_is_question(rr)) {
ldns_buffer_printf(output, "\t\\# 0");
}
} else if (ldns_rr_rd_count(rr) == 0) {
/* assert(fmt_st->flags & LDNS_FMT_SHORT); */
ldns_buffer_printf(output, "# 0");
}
for (i = 0; i < ldns_rr_rd_count(rr); i++) {
/* ldns_rdf2buffer_str handles NULL input fine! */
if ((fmt_st->flags & LDNS_FMT_ZEROIZE_RRSIGS) &&
(ldns_rr_get_type(rr) == LDNS_RR_TYPE_RRSIG) &&
((/* inception */ i == 4 &&
ldns_rdf_get_type(ldns_rr_rdf(rr, 4)) ==
LDNS_RDF_TYPE_TIME) ||
(/* expiration */ i == 5 &&
ldns_rdf_get_type(ldns_rr_rdf(rr, 5)) ==
LDNS_RDF_TYPE_TIME) ||
(/* signature */ i == 8 &&
ldns_rdf_get_type(ldns_rr_rdf(rr, 8)) ==
LDNS_RDF_TYPE_B64))) {
ldns_buffer_printf(output, "(null)");
status = ldns_buffer_status(output);
} else if ((fmt_st->flags & LDNS_FMT_PAD_SOA_SERIAL) &&
(ldns_rr_get_type(rr) == LDNS_RR_TYPE_SOA) &&
/* serial */ i == 2 &&
ldns_rdf_get_type(ldns_rr_rdf(rr, 2)) ==
LDNS_RDF_TYPE_INT32) {
ldns_buffer_printf(output, "%10lu",
(unsigned long) ldns_read_uint32(
ldns_rdf_data(ldns_rr_rdf(rr, 2))));
status = ldns_buffer_status(output);
} else {
status = ldns_rdf2buffer_str_fmt(output,
fmt, ldns_rr_rdf(rr, i));
}
if(status != LDNS_STATUS_OK)
return status;
if (i < ldns_rr_rd_count(rr) - 1) {
ldns_buffer_printf(output, " ");
}
}
/* per RR special comments - handy for DNSSEC types */
/* check to prevent question sec. rr from
* getting here */
if (ldns_rr_rd_count(rr) > 0) {
switch (ldns_rr_get_type(rr)) {
case LDNS_RR_TYPE_DNSKEY:
/* if ldns_rr_rd_count(rr) > 0
then ldns_rr_rdf(rr, 0) exists! */
if (! (fmt_st->flags & LDNS_COMMENT_KEY)) {
break;
}
flags = ldns_rdf2native_int16(ldns_rr_rdf(rr, 0));
ldns_buffer_printf(output, " ;{");
if (fmt_st->flags & LDNS_COMMENT_KEY_ID) {
ldns_buffer_printf(output, "id = %u",
(unsigned int) ldns_calc_keytag(rr));
}
if ((fmt_st->flags & LDNS_COMMENT_KEY_TYPE) &&
(flags & LDNS_KEY_ZONE_KEY)){
if (flags & LDNS_KEY_SEP_KEY) {
ldns_buffer_printf(output, " (ksk)");
} else {
ldns_buffer_printf(output, " (zsk)");
}
if (fmt_st->flags & LDNS_COMMENT_KEY_SIZE){
ldns_buffer_printf(output, ", ");
}
} else if (fmt_st->flags
& (LDNS_COMMENT_KEY_ID
|LDNS_COMMENT_KEY_SIZE)) {
ldns_buffer_printf( output, ", ");
}
if (fmt_st->flags & LDNS_COMMENT_KEY_SIZE) {
ldns_buffer_printf(output, "size = %db",
ldns_rr_dnskey_key_size(rr));
}
ldns_buffer_printf(output, "}");
break;
case LDNS_RR_TYPE_RRSIG:
if ((fmt_st->flags & LDNS_COMMENT_KEY)
&& (fmt_st->flags& LDNS_COMMENT_RRSIGS)
&& ldns_rr_rdf(rr, 6) != NULL) {
ldns_buffer_printf(output, " ;{id = %d}",
ldns_rdf2native_int16(
ldns_rr_rdf(rr, 6)));
}
break;
case LDNS_RR_TYPE_DS:
if ((fmt_st->flags & LDNS_COMMENT_BUBBLEBABBLE) &&
ldns_rr_rdf(rr, 3) != NULL) {
uint8_t *data = ldns_rdf_data(
ldns_rr_rdf(rr, 3));
size_t len = ldns_rdf_size(ldns_rr_rdf(rr, 3));
char *babble = ldns_bubblebabble(data, len);
if(babble) {
ldns_buffer_printf(output,
" ;{%s}", babble);
}
LDNS_FREE(babble);
}
break;
case LDNS_RR_TYPE_NSEC3:
if (! (fmt_st->flags & LDNS_COMMENT_FLAGS) &&
! (fmt_st->flags & LDNS_COMMENT_NSEC3_CHAIN)) {
break;
}
ldns_buffer_printf(output, " ;{");
if ((fmt_st->flags & LDNS_COMMENT_FLAGS)) {
if (ldns_nsec3_optout(rr)) {
ldns_buffer_printf(output,
" flags: optout");
} else {
ldns_buffer_printf(output," flags: -");
}
if (fmt_st->flags & LDNS_COMMENT_NSEC3_CHAIN &&
fmt_st->hashmap != NULL) {
ldns_buffer_printf(output, ", ");
}
}
if (fmt_st->flags & LDNS_COMMENT_NSEC3_CHAIN &&
fmt_st->hashmap != NULL) {
ldns_rbnode_t *node;
ldns_rdf *key = ldns_dname_label(
ldns_rr_owner(rr), 0);
if (key) {
node = ldns_rbtree_search(
fmt_st->hashmap,
(void *) key);
if (node->data) {
ldns_buffer_printf(output,
"from: ");
(void) ldns_rdf2buffer_str(
output,
ldns_dnssec_name_name(
(ldns_dnssec_name*)
node->data
));
}
ldns_rdf_deep_free(key);
}
key = ldns_b32_ext2dname(
ldns_nsec3_next_owner(rr));
if (key) {
node = ldns_rbtree_search(
fmt_st->hashmap,
(void *) key);
if (node->data) {
ldns_buffer_printf(output,
" to: ");
(void) ldns_rdf2buffer_str(
output,
ldns_dnssec_name_name(
(ldns_dnssec_name*)
node->data
));
}
ldns_rdf_deep_free(key);
}
}
ldns_buffer_printf(output, "}");
break;
default:
break;
}
}
/* last */
ldns_buffer_printf(output, "\n");
return ldns_buffer_status(output);
}
ldns_status
ldns_rr2buffer_str(ldns_buffer *output, const ldns_rr *rr)
{
return ldns_rr2buffer_str_fmt(output, ldns_output_format_default, rr);
}
ldns_status
ldns_rr_list2buffer_str_fmt(ldns_buffer *output,
const ldns_output_format *fmt, const ldns_rr_list *list)
{
uint16_t i;
for(i = 0; i < ldns_rr_list_rr_count(list); i++) {
(void) ldns_rr2buffer_str_fmt(output, fmt,
ldns_rr_list_rr(list, i));
}
return ldns_buffer_status(output);
}
ldns_status
ldns_rr_list2buffer_str(ldns_buffer *output, const ldns_rr_list *list)
{
return ldns_rr_list2buffer_str_fmt(
output, ldns_output_format_default, list);
}
ldns_status
ldns_pktheader2buffer_str(ldns_buffer *output, const ldns_pkt *pkt)
{
ldns_lookup_table *opcode = ldns_lookup_by_id(ldns_opcodes,
(int) ldns_pkt_get_opcode(pkt));
ldns_lookup_table *rcode = ldns_lookup_by_id(ldns_rcodes,
(int) ldns_pkt_get_rcode(pkt));
ldns_buffer_printf(output, ";; ->>HEADER<<- ");
if (opcode) {
ldns_buffer_printf(output, "opcode: %s, ", opcode->name);
} else {
ldns_buffer_printf(output, "opcode: ?? (%u), ",
ldns_pkt_get_opcode(pkt));
}
if (rcode) {
ldns_buffer_printf(output, "rcode: %s, ", rcode->name);
} else {
ldns_buffer_printf(output, "rcode: ?? (%u), ", ldns_pkt_get_rcode(pkt));
}
ldns_buffer_printf(output, "id: %d\n", ldns_pkt_id(pkt));
ldns_buffer_printf(output, ";; flags: ");
if (ldns_pkt_qr(pkt)) {
ldns_buffer_printf(output, "qr ");
}
if (ldns_pkt_aa(pkt)) {
ldns_buffer_printf(output, "aa ");
}
if (ldns_pkt_tc(pkt)) {
ldns_buffer_printf(output, "tc ");
}
if (ldns_pkt_rd(pkt)) {
ldns_buffer_printf(output, "rd ");
}
if (ldns_pkt_cd(pkt)) {
ldns_buffer_printf(output, "cd ");
}
if (ldns_pkt_ra(pkt)) {
ldns_buffer_printf(output, "ra ");
}
if (ldns_pkt_ad(pkt)) {
ldns_buffer_printf(output, "ad ");
}
ldns_buffer_printf(output, "; ");
ldns_buffer_printf(output, "QUERY: %u, ", ldns_pkt_qdcount(pkt));
ldns_buffer_printf(output, "ANSWER: %u, ", ldns_pkt_ancount(pkt));
ldns_buffer_printf(output, "AUTHORITY: %u, ", ldns_pkt_nscount(pkt));
ldns_buffer_printf(output, "ADDITIONAL: %u ", ldns_pkt_arcount(pkt));
return ldns_buffer_status(output);
}
/* print EDNS option data in the Dig format: 76 61 6c 69 ... */
static void
ldns_edns_hex_data2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
size_t j;
for (j = 0; j < len; j++) {
ldns_buffer_printf(output, " %02x", data[j]);
}
}
static ldns_status
ldns_edns_llq2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
/* LLQ constants */
const char* llq_errors[] = {"NO-ERROR", "SERV-FULL", "STATIC",
"FORMAT-ERR", "NO-SUCH-LLQ", "BAD-VERS", "UNKNOWN_ERR"};
const unsigned int llq_errors_num = 7;
const char* llq_opcodes[] = {"LLQ-SETUP", "LLQ-REFRESH", "LLQ-EVENT"};
const unsigned int llq_opcodes_num = 3;
uint16_t version, llq_opcode, error_code;
uint64_t llq_id;
uint32_t lease_life; /* Requested or granted life of LLQ, in seconds */
ldns_buffer_printf(output, "; Long-Lived Query:");
/* read the record */
if(len != 18) {
ldns_buffer_printf(output, " malformed LLQ ");
ldns_edns_hex_data2buffer_str(output, data, len);
return ldns_buffer_status(output);
}
version = ldns_read_uint16(data);
llq_opcode = ldns_read_uint16(data+2);
error_code = ldns_read_uint16(data+4);
memmove(&llq_id, data+6, sizeof(uint64_t));
lease_life = ldns_read_uint32(data+14);
/* print option field entires */
ldns_buffer_printf(output, "v%d ", (int)version);
if(llq_opcode < llq_opcodes_num) {
ldns_buffer_printf(output, "%s", llq_opcodes[llq_opcode]);
} else {
ldns_buffer_printf(output, "opcode %d", (int)llq_opcode);
}
if(error_code < llq_errors_num)
ldns_buffer_printf(output, " %s", llq_errors[error_code]);
else {
ldns_buffer_printf(output, " error %d", (int)error_code);
}
#ifndef USE_WINSOCK
ldns_buffer_printf(output, " id %llx lease-life %lu",
(unsigned long long)llq_id, (unsigned long)lease_life);
#else
ldns_buffer_printf(output, " id %I64x lease-life %lu",
(unsigned long long)llq_id, (unsigned long)lease_life);
#endif
return ldns_buffer_status(output);
}
static ldns_status
ldns_edns_ul2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
uint32_t lease;
ldns_buffer_printf(output, "; Update Lease:");
if(len != 4) {
ldns_buffer_printf(output, " malformed UL ");
ldns_edns_hex_data2buffer_str(output, data, len);
return ldns_buffer_status(output);
}
lease = ldns_read_uint32(data);
ldns_buffer_printf(output, "lease %lu", (unsigned long)lease);
return ldns_buffer_status(output);
}
static ldns_status
ldns_edns_nsid2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
size_t i, printed=0;
ldns_buffer_printf(output, "; NSID:");
ldns_edns_hex_data2buffer_str(output, data, len);
/* print the human-readable text string */
for(i = 0; i < len; i++) {
if(isprint((unsigned char)data[i]) || data[i] == '\t') {
if(!printed) {
ldns_buffer_printf(output, " (");
printed = 1;
}
ldns_buffer_printf(output, "%c", (char)data[i]);
}
}
if(printed)
ldns_buffer_printf(output, ")");
return ldns_buffer_status(output);
}
static ldns_status
ldns_edns_dau2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
size_t i;
ldns_lookup_table *lt;
ldns_buffer_printf(output, "; DNSSEC Algorithm Understood (DAU):");
for(i = 0; i <len; i++) {
lt = ldns_lookup_by_id(ldns_algorithms, data[i]);
if (lt && lt->name) {
ldns_buffer_printf(output, " %s", lt->name);
} else {
ldns_buffer_printf(output, " ALG%u", data[i]);
}
}
return ldns_buffer_status(output);
}
static ldns_status
ldns_edns_dhu2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
size_t i;
ldns_lookup_table *lt;
ldns_buffer_printf(output, "; DS Hash Understood (DHU):");
for(i = 0; i < len; i++) {
lt = ldns_lookup_by_id(ldns_hashes, data[i]);
if (lt && lt->name) {
ldns_buffer_printf(output, " %s", lt->name);
} else {
ldns_buffer_printf(output, " ALG%u", data[i]);
}
}
return ldns_buffer_status(output);
}
static ldns_status
ldns_edns_d3u2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
size_t i;
ldns_buffer_printf(output, "; NSEC3 Hash Understood (N3U):");
for(i=0; i<len; i++) {
if(data[i] == 1) {
ldns_buffer_printf(output, " SHA1");
} else {
ldns_buffer_printf(output, " %d", (int)data[i]);
}
}
return ldns_buffer_status(output);
}
static ldns_status
ldns_edns_subnet2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
uint16_t family;
uint8_t source, scope;
ldns_buffer_printf(output, "; CLIENT SUBNET: ");
if(len < 4) {
ldns_buffer_printf(output, "malformed subnet ");
ldns_edns_hex_data2buffer_str(output, data, len);
return ldns_buffer_status(output);
}
family = ldns_read_uint16(data);
source = data[2];
scope = data[3];
if(family == 1) {
/* IPv4 */
char buf[64];
uint8_t ip4[4];
memset(ip4, 0, sizeof(ip4));
if(len-4 > 4) {
ldns_buffer_printf(output, "trailingdata:");
ldns_edns_hex_data2buffer_str(output, data+4+4, len-4-4);
ldns_buffer_printf(output, " ");
len = 4+4;
}
memmove(ip4, data+4, len-4);
if(!inet_ntop(AF_INET, ip4, buf, (socklen_t) sizeof(buf))) {
ldns_buffer_printf(output, "ip4ntoperror ");
ldns_edns_hex_data2buffer_str(output, data+4+4, len-4-4);
} else {
ldns_buffer_printf(output, "%s", buf);
}
} else if(family == 2) {
/* IPv6 */
char buf[64];
uint8_t ip6[16];
memset(ip6, 0, sizeof(ip6));
if(len-4 > 16) {
ldns_buffer_printf(output, "trailingdata:");
ldns_edns_hex_data2buffer_str(output, data+4+16, len-4-16);
ldns_buffer_printf(output, " ");
len = 4+16;
}
memmove(ip6, data+4, len-4);
#ifdef AF_INET6
if(!inet_ntop(AF_INET6, ip6, buf, (socklen_t) sizeof(buf))) {
ldns_buffer_printf(output, "ip6ntoperror ");
ldns_edns_hex_data2buffer_str(output, data+4+4, len-4-4);
} else {
ldns_buffer_printf(output, "%s", buf);
}
#else
ldns_edns_hex_data2buffer_str(output, data+4+4, len-4-4);
#endif
} else {
/* unknown */
ldns_buffer_printf(output, "family %d ", (int)family);
ldns_edns_hex_data2buffer_str(output, data, len);
}
ldns_buffer_printf(output, "/%d scope /%d", (int)source, (int)scope);
return ldns_buffer_status(output);
}
static ldns_status
ldns_edns_expire2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
ldns_buffer_printf(output, "; EXPIRE:");
if (!(len == 0) || len == 4) {
ldns_buffer_printf(output, "malformed expire ");
ldns_edns_hex_data2buffer_str(output, data, len);
return ldns_buffer_status(output);
}
// TODO can this output be more accurate?
ldns_edns_hex_data2buffer_str(output, data, len);
return ldns_buffer_status(output);
}
static ldns_status
ldns_edns_cookie2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
ldns_buffer_printf(output, "; COOKIE:");
/* the size of an EDNS cookie is restricted by RFC 7873 */
if (!(len == 8 || (len >= 16 && len < 40))) {
ldns_buffer_printf(output, "malformed cookie ");
ldns_edns_hex_data2buffer_str(output, data, len);
}
ldns_edns_hex_data2buffer_str(output, data, len);
return ldns_buffer_status(output);
}
static ldns_status
ldns_edns_keepalive2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
uint16_t timeout;
ldns_buffer_printf(output, "; KEEPALIVE:");
if(!(len == 0 || len == 2)) {
ldns_buffer_printf(output, "malformed keepalive ");
ldns_edns_hex_data2buffer_str(output, data, len);
return ldns_buffer_status(output);
}
if(len == 0) {
ldns_buffer_printf(output, "no timeout value (only valid for client option)");
} else {
timeout = ldns_read_uint16(data);
ldns_buffer_printf(output, "timeout value in units of 100ms %u", (int)timeout);
}
return ldns_buffer_status(output);
}
static ldns_status
ldns_edns_padding2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
ldns_buffer_printf(output, "; PADDING: ");
ldns_edns_hex_data2buffer_str(output, data, len);
return ldns_buffer_status(output);
}
static ldns_status
ldns_edns_chain2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
ldns_rdf* temp = NULL;
ldns_buffer_printf(output, "; CHAIN: ");
if (ldns_str2rdf_dname(&temp, (char*) data) != LDNS_STATUS_OK) {
ldns_buffer_printf(output, "malformed chain ");
ldns_edns_hex_data2buffer_str(output, data, len);
return ldns_buffer_status(output);
}
ldns_characters2buffer_str(output, len, data);
return ldns_buffer_status(output);
}
static ldns_status
ldns_edns_key_tag2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
size_t i;
ldns_buffer_printf(output, "; KEY TAG: ");
if(len < 2 || len % 2 != 0) {
ldns_buffer_printf(output, "malformed key tag ");
ldns_edns_hex_data2buffer_str(output, data, len);
return ldns_buffer_status(output);
}
for (i = 0; i < len; i += 2) {
uint16_t tag = ldns_read_uint16(data);
ldns_buffer_printf(output, " %hu", tag);
}
return ldns_buffer_status(output);
}
static ldns_status
ldns_edns_ede2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
size_t i;
uint16_t ede;
ldns_buffer_printf(output, "; EDE:");
if(len < 2) {
ldns_buffer_printf(output, "malformed ede ");
ldns_edns_hex_data2buffer_str(output, data, len);
return ldns_buffer_status(output);
}
ede = ldns_read_uint16(data);
switch (ede) {
case LDNS_EDE_OTHER:
ldns_buffer_printf(output, " 0 (Other): ");
break;
case LDNS_EDE_UNSUPPORTED_DNSKEY_ALG:
ldns_buffer_printf(output, " 1 (Unsupported DNSKEY Algorithm)");
break;
case LDNS_EDE_UNSUPPORTED_DS_DIGEST:
ldns_buffer_printf(output, " 2 (Unsupported DS Digest type)");
break;
case LDNS_EDE_STALE_ANSWER:
ldns_buffer_printf(output, " 3 (Stale Answer)");
break;
case LDNS_EDE_FORGED_ANSWER:
ldns_buffer_printf(output, " 4 (Forged Answer)");
break;
case LDNS_EDE_DNSSEC_INDETERMINATE:
ldns_buffer_printf(output, " 5 (DNSSEC Indeterminate)");
break;
case LDNS_EDE_DNSSEC_BOGUS:
ldns_buffer_printf(output, " 6 (DNSSEC Bogus)");
break;
case LDNS_EDE_SIGNATURE_EXPIRED:
ldns_buffer_printf(output, " 7 (Signature Expired)");
break;
case LDNS_EDE_SIGNATURE_NOT_YET_VALID:
ldns_buffer_printf(output, " 8 (Signature Not Yet Valid)");
break;
case LDNS_EDE_DNSKEY_MISSING:
ldns_buffer_printf(output, " 9 (DNSKEY Missing)");
break;
case LDNS_EDE_RRSIGS_MISSING:
ldns_buffer_printf(output, " 10 (RRSIGs Missing)");
break;
case LDNS_EDE_NO_ZONE_KEY_BIT_SET:
ldns_buffer_printf(output, " 11 (No Zone Key Bit Set)");
break;
case LDNS_EDE_NSEC_MISSING:
ldns_buffer_printf(output, " 12 (NSEC Missing)");
break;
case LDNS_EDE_CACHED_ERROR:
ldns_buffer_printf(output, " 13 (Cached Error)");
break;
case LDNS_EDE_NOT_READY:
ldns_buffer_printf(output, " 14 (Not Ready)");
break;
case LDNS_EDE_BLOCKED:
ldns_buffer_printf(output, " 15 (Blocked)");
break;
case LDNS_EDE_CENSORED:
ldns_buffer_printf(output, " 16 (Censored)");
break;
case LDNS_EDE_FILTERED:
ldns_buffer_printf(output, " 17 (Filtered)");
break;
case LDNS_EDE_PROHIBITED:
ldns_buffer_printf(output, " 18 (Prohibited)");
break;
case LDNS_EDE_STALE_NXDOMAIN_ANSWER:
ldns_buffer_printf(output, " 19 (NXDOMAIN Answer)");
break;
case LDNS_EDE_NOT_AUTHORITATIVE:
ldns_buffer_printf(output, " 20 (Not Authoritative)");
break;
case LDNS_EDE_NOT_SUPPORTED:
ldns_buffer_printf(output, " 21 (Not Supported)");
break;
case LDNS_EDE_NO_REACHABLE_AUTHORITY:
ldns_buffer_printf(output, " 22 (No Reachable Authority)");
break;
case LDNS_EDE_NETWORK_ERROR:
ldns_buffer_printf(output, " 23 (Network Error)");
break;
case LDNS_EDE_INVALID_DATA:
ldns_buffer_printf(output, " 24 (Invalid Data)");
break;
case LDNS_EDE_SIGNATURE_EXPIRED_BEFORE_VALID:
ldns_buffer_printf(output, " 25 (Signature Expired Before Valid)");
break;
case LDNS_EDE_TOO_EARLY:
ldns_buffer_printf(output, " 26 (Too Early)");
break;
default:
ldns_buffer_printf(output, " %02x", data[0]);
ldns_buffer_printf(output, " %02x", data[1]);
break;
}
/* skip the EDE code in the output */
data += 2;
len -= 2;
if (len > 2) {
/* format the hex bytes */
ldns_buffer_printf(output, ":");
for (i = 0; i < len; i++) {
ldns_buffer_printf(output, " %02x", data[i]);
}
/* format the human-readable string */
ldns_buffer_printf(output, " (");
ldns_characters2buffer_str(output, len, data);
ldns_buffer_printf(output, ")");
}
return ldns_buffer_status(output);
}
static ldns_status
ldns_edns_client_tag2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
ldns_buffer_printf(output, "; CLIENT-TAG:");
if (len > 2) {
ldns_buffer_printf(output, "malformed client-tag ");
ldns_edns_hex_data2buffer_str(output, data, len);
return ldns_buffer_status(output);
}
ldns_edns_hex_data2buffer_str(output, data, len);
return ldns_buffer_status(output);
}
static ldns_status
ldns_edns_server_tag2buffer_str(ldns_buffer* output, uint8_t* data, size_t len)
{
ldns_buffer_printf(output, "; SERVER-TAG:");
if (len > 2) {
ldns_buffer_printf(output, "malformed server-tag ");
ldns_edns_hex_data2buffer_str(output, data, len);
return ldns_buffer_status(output);
}
ldns_edns_hex_data2buffer_str(output, data, len);
return ldns_buffer_status(output);
}
ldns_status
ldns_edns_option_list2buffer_str(ldns_buffer *output, ldns_edns_option_list* edns_list)
{
size_t count = ldns_edns_option_list_get_count(edns_list);
size_t i, size;
uint8_t* data;
for (i = 0; i < count; i++) {
ldns_edns_option_code code;
ldns_edns_option* edns = ldns_edns_option_list_get_option(edns_list, i);
if (!edns) {
break;
}
code = ldns_edns_get_code(edns);
size = ldns_edns_get_size(edns);
data = ldns_edns_get_data(edns);
switch(code) {
case LDNS_EDNS_LLQ:
ldns_edns_llq2buffer_str(output, data, size);
break;
case LDNS_EDNS_UL:
ldns_edns_ul2buffer_str(output, data, size);
break;
case LDNS_EDNS_NSID:
ldns_edns_nsid2buffer_str(output, data, size);
break;
case LDNS_EDNS_DAU:
ldns_edns_dau2buffer_str(output, data, size);
break;
case LDNS_EDNS_DHU:
ldns_edns_dhu2buffer_str(output, data, size);
break;
case LDNS_EDNS_N3U:
ldns_edns_d3u2buffer_str(output, data, size);
break;
case LDNS_EDNS_CLIENT_SUBNET:
ldns_edns_subnet2buffer_str(output, data, size);
break;
case LDNS_EDNS_EXPIRE:
ldns_edns_expire2buffer_str(output, data, size);
break;
case LDNS_EDNS_COOKIE:
ldns_edns_cookie2buffer_str(output, data, size);
break;
case LDNS_EDNS_KEEPALIVE:
ldns_edns_keepalive2buffer_str(output, data, size);
break;
case LDNS_EDNS_PADDING:
ldns_edns_padding2buffer_str(output, data, size);
break;
case LDNS_EDNS_CHAIN:
ldns_edns_chain2buffer_str(output, data, size);
break;
case LDNS_EDNS_KEY_TAG:
ldns_edns_key_tag2buffer_str(output, data, size);
break;
case LDNS_EDNS_EDE:
ldns_edns_ede2buffer_str(output, data, size);
break;
case LDNS_EDNS_CLIENT_TAG:
ldns_edns_client_tag2buffer_str(output, data, size);
break;
case LDNS_EDNS_SERVER_TAG:
ldns_edns_server_tag2buffer_str(output, data, size);
break;
default:
ldns_buffer_printf(output, "; OPT=%d:", code);
ldns_edns_hex_data2buffer_str(output, data, size);
break;
}
ldns_buffer_printf(output, "\n");
}
return ldns_buffer_status(output);
}
ldns_status
ldns_pkt2buffer_str_fmt(ldns_buffer *output,
const ldns_output_format *fmt, const ldns_pkt *pkt)
{
uint16_t i;
ldns_status status = LDNS_STATUS_OK;
char *tmp;
struct timeval time;
time_t time_tt;
int short_fmt = fmt && (fmt->flags & LDNS_FMT_SHORT);
if (!pkt) {
ldns_buffer_printf(output, "null");
return LDNS_STATUS_OK;
}
if (!ldns_buffer_status_ok(output)) {
return ldns_buffer_status(output);
}
if (!short_fmt) {
status = ldns_pktheader2buffer_str(output, pkt);
if (status != LDNS_STATUS_OK) {
return status;
}
ldns_buffer_printf(output, "\n");
ldns_buffer_printf(output, ";; QUESTION SECTION:\n;; ");
for (i = 0; i < ldns_pkt_qdcount(pkt); i++) {
status = ldns_rr2buffer_str_fmt(output, fmt,
ldns_rr_list_rr(
ldns_pkt_question(pkt), i));
if (status != LDNS_STATUS_OK) {
return status;
}
}
ldns_buffer_printf(output, "\n");
ldns_buffer_printf(output, ";; ANSWER SECTION:\n");
}
for (i = 0; i < ldns_pkt_ancount(pkt); i++) {
status = ldns_rr2buffer_str_fmt(output, fmt,
ldns_rr_list_rr(
ldns_pkt_answer(pkt), i));
if (status != LDNS_STATUS_OK) {
return status;
}
}
if (!short_fmt) {
ldns_buffer_printf(output, "\n");
ldns_buffer_printf(output, ";; AUTHORITY SECTION:\n");
for (i = 0; i < ldns_pkt_nscount(pkt); i++) {
status = ldns_rr2buffer_str_fmt(output, fmt,
ldns_rr_list_rr(
ldns_pkt_authority(pkt), i));
if (status != LDNS_STATUS_OK) {
return status;
}
}
ldns_buffer_printf(output, "\n");
ldns_buffer_printf(output, ";; ADDITIONAL SECTION:\n");
for (i = 0; i < ldns_pkt_arcount(pkt); i++) {
status = ldns_rr2buffer_str_fmt(output, fmt,
ldns_rr_list_rr(
ldns_pkt_additional(pkt), i));
if (status != LDNS_STATUS_OK) {
return status;
}
}
ldns_buffer_printf(output, "\n");
/* add some further fields */
ldns_buffer_printf(output, ";; Query time: %d msec\n",
ldns_pkt_querytime(pkt));
if (ldns_pkt_edns(pkt)) {
ldns_buffer_printf(output,
";; EDNS: version %u; flags:",
ldns_pkt_edns_version(pkt));
if (ldns_pkt_edns_do(pkt)) {
ldns_buffer_printf(output, " do");
}
/* the extended rcode is the value set, shifted four bits,
* and or'd with the original rcode */
if (ldns_pkt_edns_extended_rcode(pkt)) {
ldns_buffer_printf(output, " ; ext-rcode: %d",
(ldns_pkt_edns_extended_rcode(pkt) << 4 | ldns_pkt_get_rcode(pkt)));
}
ldns_buffer_printf(output, " ; udp: %u\n",
ldns_pkt_edns_udp_size(pkt));
if (pkt->_edns_list)
ldns_edns_option_list2buffer_str(output, pkt->_edns_list);
else if (ldns_pkt_edns_data(pkt)) {
ldns_edns_option_list* edns_list;
/* parse the EDNS data into separate EDNS options
* and add them to the list */
if ((edns_list = pkt_edns_data2edns_option_list(ldns_pkt_edns_data(pkt)))) {
ldns_edns_option_list2buffer_str(output, edns_list);
ldns_edns_option_list_deep_free(edns_list);
} else {
ldns_buffer_printf(output, ";; Data: ");
(void)ldns_rdf2buffer_str(output, ldns_pkt_edns_data(pkt));
ldns_buffer_printf(output, "\n");
}
}
}
if (ldns_pkt_tsig(pkt)) {
ldns_buffer_printf(output, ";; TSIG:\n;; ");
(void) ldns_rr2buffer_str_fmt(
output, fmt, ldns_pkt_tsig(pkt));
ldns_buffer_printf(output, "\n");
}
if (ldns_pkt_answerfrom(pkt)) {
tmp = ldns_rdf2str(ldns_pkt_answerfrom(pkt));
ldns_buffer_printf(output, ";; SERVER: %s\n", tmp);
LDNS_FREE(tmp);
}
time = ldns_pkt_timestamp(pkt);
time_tt = (time_t)time.tv_sec;
ldns_buffer_printf(output, ";; WHEN: %s",
(char*)ctime(&time_tt));
ldns_buffer_printf(output, ";; MSG SIZE rcvd: %d\n",
(int)ldns_pkt_size(pkt));
}
return status;
}
ldns_status
ldns_pkt2buffer_str(ldns_buffer *output, const ldns_pkt *pkt)
{
return ldns_pkt2buffer_str_fmt(output, ldns_output_format_default, pkt);
}
#ifdef HAVE_SSL
static ldns_status
ldns_hmac_key2buffer_str(ldns_buffer *output, const ldns_key *k)
{
ldns_status status;
size_t i;
ldns_rdf *b64_bignum;
ldns_buffer_printf(output, "Key: ");
i = ldns_key_hmac_size(k);
b64_bignum = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_B64, i, ldns_key_hmac_key(k));
status = ldns_rdf2buffer_str(output, b64_bignum);
ldns_rdf_deep_free(b64_bignum);
ldns_buffer_printf(output, "\n");
return status;
}
#endif
#if defined(HAVE_SSL) && defined(USE_GOST)
static ldns_status
ldns_gost_key2buffer_str(ldns_buffer *output, EVP_PKEY *p)
{
unsigned char* pp = NULL;
int ret;
ldns_rdf *b64_bignum;
ldns_status status;
ldns_buffer_printf(output, "GostAsn1: ");
ret = i2d_PrivateKey(p, &pp);
b64_bignum = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_B64, (size_t)ret, pp);
status = ldns_rdf2buffer_str(output, b64_bignum);
ldns_rdf_deep_free(b64_bignum);
OPENSSL_free(pp);
ldns_buffer_printf(output, "\n");
return status;
}
#endif
#if defined(HAVE_SSL) && defined(USE_ED25519)
static ldns_status
ldns_ed25519_key2buffer_str(ldns_buffer *output, EVP_PKEY *p)
{
unsigned char* pp = NULL;
int ret;
ldns_rdf *b64_bignum;
ldns_status status;
ldns_buffer_printf(output, "PrivateKey: ");
ret = i2d_PrivateKey(p, &pp);
/* 16 byte asn (302e020100300506032b657004220420) + 32byte key */
if(ret != 16 + 32) {
OPENSSL_free(pp);
return LDNS_STATUS_ERR;
}
b64_bignum = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_B64,
(size_t)ret-16, pp+16);
status = ldns_rdf2buffer_str(output, b64_bignum);
ldns_rdf_deep_free(b64_bignum);
OPENSSL_free(pp);
ldns_buffer_printf(output, "\n");
return status;
}
#endif
#if defined(HAVE_SSL) && defined(USE_ED448)
static ldns_status
ldns_ed448_key2buffer_str(ldns_buffer *output, EVP_PKEY *p)
{
unsigned char* pp = NULL;
int ret;
ldns_rdf *b64_bignum;
ldns_status status;
ldns_buffer_printf(output, "PrivateKey: ");
ret = i2d_PrivateKey(p, &pp);
/* some-ASN + 57byte key */
if(ret != 16 + 57) {
OPENSSL_free(pp);
return LDNS_STATUS_ERR;
}
b64_bignum = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_B64,
(size_t)ret-16, pp+16);
status = ldns_rdf2buffer_str(output, b64_bignum);
ldns_rdf_deep_free(b64_bignum);
OPENSSL_free(pp);
ldns_buffer_printf(output, "\n");
return status;
}
#endif
#if defined(HAVE_SSL)
static int
ldns_print_bignum_b64_line(ldns_buffer* output, const char* label, const BIGNUM* num)
{
unsigned char *bignumbuf = LDNS_XMALLOC(unsigned char, LDNS_MAX_KEYLEN);
if(!bignumbuf) return 0;
ldns_buffer_printf(output, "%s: ", label);
if(num) {
ldns_rdf *b64_bignum = NULL;
int i = BN_bn2bin(num, bignumbuf);
if (i > LDNS_MAX_KEYLEN) {
LDNS_FREE(bignumbuf);
return 0;
}
b64_bignum = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_B64, (size_t)i, bignumbuf);
if (ldns_rdf2buffer_str(output, b64_bignum) != LDNS_STATUS_OK) {
ldns_rdf_deep_free(b64_bignum);
LDNS_FREE(bignumbuf);
return 0;
}
ldns_rdf_deep_free(b64_bignum);
ldns_buffer_printf(output, "\n");
} else {
ldns_buffer_printf(output, "(Not available)\n");
}
LDNS_FREE(bignumbuf);
return 1;
}
#endif
ldns_status
ldns_key2buffer_str(ldns_buffer *output, const ldns_key *k)
{
ldns_status status = LDNS_STATUS_OK;
unsigned char *bignum;
#ifdef HAVE_SSL
RSA *rsa;
#ifdef USE_DSA
DSA *dsa;
#endif /* USE_DSA */
#endif /* HAVE_SSL */
if (!k) {
return LDNS_STATUS_ERR;
}
bignum = LDNS_XMALLOC(unsigned char, LDNS_MAX_KEYLEN);
if (!bignum) {
return LDNS_STATUS_ERR;
}
if (ldns_buffer_status_ok(output)) {
#ifdef HAVE_SSL
switch(ldns_key_algorithm(k)) {
case LDNS_SIGN_RSASHA1:
case LDNS_SIGN_RSASHA1_NSEC3:
case LDNS_SIGN_RSASHA256:
case LDNS_SIGN_RSASHA512:
case LDNS_SIGN_RSAMD5:
/* copied by looking at dnssec-keygen output */
/* header */
rsa = ldns_key_rsa_key(k);
ldns_buffer_printf(output,"Private-key-format: v1.2\n");
switch(ldns_key_algorithm(k)) {
case LDNS_SIGN_RSAMD5:
ldns_buffer_printf(output,
"Algorithm: %u (RSA)\n",
LDNS_RSAMD5);
break;
case LDNS_SIGN_RSASHA1:
ldns_buffer_printf(output,
"Algorithm: %u (RSASHA1)\n",
LDNS_RSASHA1);
break;
case LDNS_SIGN_RSASHA1_NSEC3:
ldns_buffer_printf(output,
"Algorithm: %u (RSASHA1_NSEC3)\n",
LDNS_RSASHA1_NSEC3);
break;
#ifdef USE_SHA2
case LDNS_SIGN_RSASHA256:
ldns_buffer_printf(output,
"Algorithm: %u (RSASHA256)\n",
LDNS_RSASHA256);
break;
case LDNS_SIGN_RSASHA512:
ldns_buffer_printf(output,
"Algorithm: %u (RSASHA512)\n",
LDNS_RSASHA512);
break;
#endif
default:
#ifdef STDERR_MSGS
fprintf(stderr, "Warning: unknown signature ");
fprintf(stderr,
"algorithm type %u\n",
ldns_key_algorithm(k));
#endif
ldns_buffer_printf(output,
"Algorithm: %u (Unknown)\n",
ldns_key_algorithm(k));
break;
}
/* print to buf, convert to bin, convert to b64,
* print to buf */
#ifndef S_SPLINT_S
if(1) {
const BIGNUM *n=NULL, *e=NULL, *d=NULL,
*p=NULL, *q=NULL, *dmp1=NULL,
*dmq1=NULL, *iqmp=NULL;
#if OPENSSL_VERSION_NUMBER < 0x10100000 || (defined(HAVE_LIBRESSL) && LIBRESSL_VERSION_NUMBER < 0x20700000)
n = rsa->n;
e = rsa->e;
d = rsa->d;
p = rsa->p;
q = rsa->q;
dmp1 = rsa->dmp1;
dmq1 = rsa->dmq1;
iqmp = rsa->iqmp;
#else
RSA_get0_key(rsa, &n, &e, &d);
RSA_get0_factors(rsa, &p, &q);
RSA_get0_crt_params(rsa, &dmp1,
&dmq1, &iqmp);
#endif
if(!ldns_print_bignum_b64_line(output, "Modulus", n))
goto error;
if(!ldns_print_bignum_b64_line(output, "PublicExponent", e))
goto error;
if(!ldns_print_bignum_b64_line(output, "PrivateExponent", d))
goto error;
if(!ldns_print_bignum_b64_line(output, "Prime1", p))
goto error;
if(!ldns_print_bignum_b64_line(output, "Prime2", q))
goto error;
if(!ldns_print_bignum_b64_line(output, "Exponent1", dmp1))
goto error;
if(!ldns_print_bignum_b64_line(output, "Exponent2", dmq1))
goto error;
if(!ldns_print_bignum_b64_line(output, "Coefficient", iqmp))
goto error;
}
#endif /* splint */
RSA_free(rsa);
break;
#ifdef USE_DSA
case LDNS_SIGN_DSA:
case LDNS_SIGN_DSA_NSEC3:
dsa = ldns_key_dsa_key(k);
ldns_buffer_printf(output,"Private-key-format: v1.2\n");
if (ldns_key_algorithm(k) == LDNS_SIGN_DSA) {
ldns_buffer_printf(output,"Algorithm: 3 (DSA)\n");
} else if (ldns_key_algorithm(k) == LDNS_SIGN_DSA_NSEC3) {
ldns_buffer_printf(output,"Algorithm: 6 (DSA_NSEC3)\n");
}
/* print to buf, convert to bin, convert to b64,
* print to buf */
if(1) {
const BIGNUM *p=NULL, *q=NULL, *g=NULL,
*priv_key=NULL, *pub_key=NULL;
#if OPENSSL_VERSION_NUMBER < 0x10100000 || (defined(HAVE_LIBRESSL) && LIBRESSL_VERSION_NUMBER < 0x20700000)
#ifndef S_SPLINT_S
p = dsa->p;
q = dsa->q;
g = dsa->g;
priv_key = dsa->priv_key;
pub_key = dsa->pub_key;
#endif /* splint */
#else
DSA_get0_pqg(dsa, &p, &q, &g);
DSA_get0_key(dsa, &pub_key, &priv_key);
#endif
if(!ldns_print_bignum_b64_line(output, "Prime(p)", p))
goto error;
if(!ldns_print_bignum_b64_line(output, "Subprime(q)", q))
goto error;
if(!ldns_print_bignum_b64_line(output, "Base(g)", g))
goto error;
if(!ldns_print_bignum_b64_line(output, "Private_value(x)", priv_key))
goto error;
if(!ldns_print_bignum_b64_line(output, "Public_value(y)", pub_key))
goto error;
}
break;
#endif /* USE_DSA */
case LDNS_SIGN_ECC_GOST:
/* no format defined, use blob */
#if defined(HAVE_SSL) && defined(USE_GOST)
ldns_buffer_printf(output, "Private-key-format: v1.2\n");
ldns_buffer_printf(output, "Algorithm: %d (ECC-GOST)\n", LDNS_SIGN_ECC_GOST);
status = ldns_gost_key2buffer_str(output,
#ifndef S_SPLINT_S
k->_key.key
#else
NULL
#endif
);
#else
goto error;
#endif /* GOST */
break;
case LDNS_SIGN_ECDSAP256SHA256:
case LDNS_SIGN_ECDSAP384SHA384:
#ifdef USE_ECDSA
ldns_buffer_printf(output, "Private-key-format: v1.2\n");
ldns_buffer_printf(output, "Algorithm: %d (", ldns_key_algorithm(k));
status=ldns_algorithm2buffer_str(output, (ldns_algorithm)ldns_key_algorithm(k));
#ifndef S_SPLINT_S
ldns_buffer_printf(output, ")\n");
if(k->_key.key) {
EC_KEY* ec = EVP_PKEY_get1_EC_KEY(k->_key.key);
const BIGNUM* b = EC_KEY_get0_private_key(ec);
if(!ldns_print_bignum_b64_line(output, "PrivateKey", b))
goto error;
/* down reference count in EC_KEY
* its still assigned to the PKEY */
EC_KEY_free(ec);
}
#endif /* splint */
#else
goto error;
#endif /* ECDSA */
break;
#ifdef USE_ED25519
case LDNS_SIGN_ED25519:
ldns_buffer_printf(output, "Private-key-format: v1.2\n");
ldns_buffer_printf(output, "Algorithm: %d (", ldns_key_algorithm(k));
status=ldns_algorithm2buffer_str(output, (ldns_algorithm)ldns_key_algorithm(k));
ldns_buffer_printf(output, ")\n");
if (status) break;
status = ldns_ed25519_key2buffer_str(output,
k->_key.key);
break;
#endif /* USE_ED25519 */
#ifdef USE_ED448
case LDNS_SIGN_ED448:
ldns_buffer_printf(output, "Private-key-format: v1.2\n");
ldns_buffer_printf(output, "Algorithm: %d (", ldns_key_algorithm(k));
status=ldns_algorithm2buffer_str(output, (ldns_algorithm)ldns_key_algorithm(k));
ldns_buffer_printf(output, ")\n");
if (status) break;
status = ldns_ed448_key2buffer_str(output,
k->_key.key);
break;
#endif /* USE_ED448 */
case LDNS_SIGN_HMACMD5:
/* there's not much of a format defined for TSIG */
/* It's just a binary blob, Same for all algorithms */
ldns_buffer_printf(output, "Private-key-format: v1.2\n");
ldns_buffer_printf(output, "Algorithm: 157 (HMAC_MD5)\n");
status = ldns_hmac_key2buffer_str(output, k);
break;
case LDNS_SIGN_HMACSHA1:
ldns_buffer_printf(output, "Private-key-format: v1.2\n");
ldns_buffer_printf(output, "Algorithm: 158 (HMAC_SHA1)\n");
status = ldns_hmac_key2buffer_str(output, k);
break;
case LDNS_SIGN_HMACSHA224:
ldns_buffer_printf(output, "Private-key-format: v1.2\n");
ldns_buffer_printf(output, "Algorithm: 162 (HMAC_SHA224)\n");
status = ldns_hmac_key2buffer_str(output, k);
break;
case LDNS_SIGN_HMACSHA256:
ldns_buffer_printf(output, "Private-key-format: v1.2\n");
ldns_buffer_printf(output, "Algorithm: 159 (HMAC_SHA256)\n");
status = ldns_hmac_key2buffer_str(output, k);
break;
case LDNS_SIGN_HMACSHA384:
ldns_buffer_printf(output, "Private-key-format: v1.2\n");
ldns_buffer_printf(output, "Algorithm: 164 (HMAC_SHA384)\n");
status = ldns_hmac_key2buffer_str(output, k);
break;
case LDNS_SIGN_HMACSHA512:
ldns_buffer_printf(output, "Private-key-format: v1.2\n");
ldns_buffer_printf(output, "Algorithm: 165 (HMAC_SHA512)\n");
status = ldns_hmac_key2buffer_str(output, k);
break;
}
#endif /* HAVE_SSL */
} else {
LDNS_FREE(bignum);
return ldns_buffer_status(output);
}
LDNS_FREE(bignum);
return status;
#ifdef HAVE_SSL
/* compiles warn the label isn't used */
error:
LDNS_FREE(bignum);
return LDNS_STATUS_ERR;
#endif /* HAVE_SSL */
}
/*
* Zero terminate the buffer and copy data.
*/
char *
ldns_buffer2str(ldns_buffer *buffer)
{
char *str;
/* check if buffer ends with \0, if not, and
if there is space, add it */
if (*(ldns_buffer_at(buffer, ldns_buffer_position(buffer))) != 0) {
if (!ldns_buffer_reserve(buffer, 1)) {
return NULL;
}
ldns_buffer_write_char(buffer, (uint8_t) '\0');
if (!ldns_buffer_set_capacity(buffer, ldns_buffer_position(buffer))) {
return NULL;
}
}
str = strdup((const char *)ldns_buffer_begin(buffer));
if(!str) {
return NULL;
}
return str;
}
/*
* Zero terminate the buffer and export data.
*/
char *
ldns_buffer_export2str(ldns_buffer *buffer)
{
/* Append '\0' as string terminator */
if (! ldns_buffer_reserve(buffer, 1)) {
return NULL;
}
ldns_buffer_write_char(buffer, 0);
/* reallocate memory to the size of the string and export */
ldns_buffer_set_capacity(buffer, ldns_buffer_position(buffer));
return ldns_buffer_export(buffer);
}
char *
ldns_rdf2str(const ldns_rdf *rdf)
{
char *result = NULL;
ldns_buffer *tmp_buffer = ldns_buffer_new(LDNS_MAX_PACKETLEN);
if (!tmp_buffer) {
return NULL;
}
if (ldns_rdf2buffer_str(tmp_buffer, rdf) == LDNS_STATUS_OK) {
/* export and return string, destroy rest */
result = ldns_buffer_export2str(tmp_buffer);
}
ldns_buffer_free(tmp_buffer);
return result;
}
char *
ldns_rr2str_fmt(const ldns_output_format *fmt, const ldns_rr *rr)
{
char *result = NULL;
ldns_buffer *tmp_buffer = ldns_buffer_new(LDNS_MAX_PACKETLEN);
if (!tmp_buffer) {
return NULL;
}
if (ldns_rr2buffer_str_fmt(tmp_buffer, fmt, rr)
== LDNS_STATUS_OK) {
/* export and return string, destroy rest */
result = ldns_buffer_export2str(tmp_buffer);
}
ldns_buffer_free(tmp_buffer);
return result;
}
char *
ldns_rr2str(const ldns_rr *rr)
{
return ldns_rr2str_fmt(ldns_output_format_default, rr);
}
char *
ldns_pkt2str_fmt(const ldns_output_format *fmt, const ldns_pkt *pkt)
{
char *result = NULL;
ldns_buffer *tmp_buffer = ldns_buffer_new(LDNS_MAX_PACKETLEN);
if (!tmp_buffer) {
return NULL;
}
if (ldns_pkt2buffer_str_fmt(tmp_buffer, fmt, pkt)
== LDNS_STATUS_OK) {
/* export and return string, destroy rest */
result = ldns_buffer_export2str(tmp_buffer);
}
ldns_buffer_free(tmp_buffer);
return result;
}
char *
ldns_pkt2str(const ldns_pkt *pkt)
{
return ldns_pkt2str_fmt(ldns_output_format_default, pkt);
}
char *
ldns_key2str(const ldns_key *k)
{
char *result = NULL;
ldns_buffer *tmp_buffer = ldns_buffer_new(LDNS_MAX_PACKETLEN);
if (!tmp_buffer) {
return NULL;
}
if (ldns_key2buffer_str(tmp_buffer, k) == LDNS_STATUS_OK) {
/* export and return string, destroy rest */
result = ldns_buffer_export2str(tmp_buffer);
}
ldns_buffer_free(tmp_buffer);
return result;
}
char *
ldns_rr_list2str_fmt(const ldns_output_format *fmt, const ldns_rr_list *list)
{
char *result = NULL;
ldns_buffer *tmp_buffer = ldns_buffer_new(LDNS_MAX_PACKETLEN);
if (!tmp_buffer) {
return NULL;
}
if (list) {
if (ldns_rr_list2buffer_str_fmt(
tmp_buffer, fmt, list)
== LDNS_STATUS_OK) {
}
} else {
if (fmt == NULL) {
fmt = ldns_output_format_default;
}
if (fmt->flags & LDNS_COMMENT_NULLS) {
ldns_buffer_printf(tmp_buffer, "; (null)\n");
}
}
/* export and return string, destroy rest */
result = ldns_buffer_export2str(tmp_buffer);
ldns_buffer_free(tmp_buffer);
return result;
}
char *
ldns_rr_list2str(const ldns_rr_list *list)
{
return ldns_rr_list2str_fmt(ldns_output_format_default, list);
}
void
ldns_rdf_print(FILE *output, const ldns_rdf *rdf)
{
char *str = ldns_rdf2str(rdf);
if (str) {
fprintf(output, "%s", str);
} else {
fprintf(output, ";Unable to convert rdf to string\n");
}
LDNS_FREE(str);
}
void
ldns_rr_print_fmt(FILE *output,
const ldns_output_format *fmt, const ldns_rr *rr)
{
char *str = ldns_rr2str_fmt(fmt, rr);
if (str) {
fprintf(output, "%s", str);
} else {
fprintf(output, ";Unable to convert rr to string\n");
}
LDNS_FREE(str);
}
void
ldns_rr_print(FILE *output, const ldns_rr *rr)
{
ldns_rr_print_fmt(output, ldns_output_format_default, rr);
}
void
ldns_pkt_print_fmt(FILE *output,
const ldns_output_format *fmt, const ldns_pkt *pkt)
{
char *str = ldns_pkt2str_fmt(fmt, pkt);
if (str) {
fprintf(output, "%s", str);
} else {
fprintf(output, ";Unable to convert packet to string\n");
}
LDNS_FREE(str);
}
void
ldns_pkt_print(FILE *output, const ldns_pkt *pkt)
{
ldns_pkt_print_fmt(output, ldns_output_format_default, pkt);
}
void
ldns_rr_list_print_fmt(FILE *output,
const ldns_output_format *fmt, const ldns_rr_list *lst)
{
size_t i;
for (i = 0; i < ldns_rr_list_rr_count(lst); i++) {
ldns_rr_print_fmt(output, fmt, ldns_rr_list_rr(lst, i));
}
}
void
ldns_rr_list_print(FILE *output, const ldns_rr_list *lst)
{
ldns_rr_list_print_fmt(output, ldns_output_format_default, lst);
}
void
ldns_resolver_print_fmt(FILE *output,
const ldns_output_format *fmt, const ldns_resolver *r)
{
uint16_t i;
ldns_rdf **n;
ldns_rdf **s;
size_t *rtt;
if (!r) {
return;
}
n = ldns_resolver_nameservers(r);
s = ldns_resolver_searchlist(r);
rtt = ldns_resolver_rtt(r);
fprintf(output, "port: %d\n", (int)ldns_resolver_port(r));
fprintf(output, "edns0 size: %d\n", (int)ldns_resolver_edns_udp_size(r));
fprintf(output, "use ip6: %d\n", (int)ldns_resolver_ip6(r));
fprintf(output, "recursive: %d\n", ldns_resolver_recursive(r));
fprintf(output, "usevc: %d\n", ldns_resolver_usevc(r));
fprintf(output, "igntc: %d\n", ldns_resolver_igntc(r));
fprintf(output, "fail: %d\n", ldns_resolver_fail(r));
fprintf(output, "retry: %d\n", (int)ldns_resolver_retry(r));
fprintf(output, "retrans: %d\n", (int)ldns_resolver_retrans(r));
fprintf(output, "fallback: %d\n", ldns_resolver_fallback(r));
fprintf(output, "random: %d\n", ldns_resolver_random(r));
fprintf(output, "timeout: %d\n", (int)ldns_resolver_timeout(r).tv_sec);
fprintf(output, "dnssec: %d\n", ldns_resolver_dnssec(r));
fprintf(output, "dnssec cd: %d\n", ldns_resolver_dnssec_cd(r));
fprintf(output, "trust anchors (%d listed):\n",
(int)ldns_rr_list_rr_count(ldns_resolver_dnssec_anchors(r)));
ldns_rr_list_print_fmt(output, fmt, ldns_resolver_dnssec_anchors(r));
fprintf(output, "tsig: %s %s\n",
ldns_resolver_tsig_keyname(r)?ldns_resolver_tsig_keyname(r):"-",
ldns_resolver_tsig_algorithm(r)?ldns_resolver_tsig_algorithm(r):"-");
fprintf(output, "debug: %d\n", ldns_resolver_debug(r));
fprintf(output, "default domain: ");
ldns_rdf_print(output, ldns_resolver_domain(r));
fprintf(output, "\n");
fprintf(output, "apply default domain: %d\n", ldns_resolver_defnames(r));
fprintf(output, "searchlist (%d listed):\n", (int)ldns_resolver_searchlist_count(r));
for (i = 0; i < ldns_resolver_searchlist_count(r); i++) {
fprintf(output, "\t");
ldns_rdf_print(output, s[i]);
fprintf(output, "\n");
}
fprintf(output, "apply search list: %d\n", ldns_resolver_dnsrch(r));
fprintf(output, "nameservers (%d listed):\n", (int)ldns_resolver_nameserver_count(r));
for (i = 0; i < ldns_resolver_nameserver_count(r); i++) {
fprintf(output, "\t");
ldns_rdf_print(output, n[i]);
switch ((int)rtt[i]) {
case LDNS_RESOLV_RTT_MIN:
fprintf(output, " - reachable\n");
break;
case LDNS_RESOLV_RTT_INF:
fprintf(output, " - unreachable\n");
break;
}
}
}
void
ldns_resolver_print(FILE *output, const ldns_resolver *r)
{
ldns_resolver_print_fmt(output, ldns_output_format_default, r);
}
void
ldns_zone_print_fmt(FILE *output,
const ldns_output_format *fmt, const ldns_zone *z)
{
if(ldns_zone_soa(z))
ldns_rr_print_fmt(output, fmt, ldns_zone_soa(z));
ldns_rr_list_print_fmt(output, fmt, ldns_zone_rrs(z));
}
void
ldns_zone_print(FILE *output, const ldns_zone *z)
{
ldns_zone_print_fmt(output, ldns_output_format_default, z);
}
ldns_buffer_free
void ldns_buffer_free(ldns_buffer *buffer)
frees the buffer.
Definition buffer.c:137
ldns_buffer
struct ldns_struct_buffer ldns_buffer
Definition buffer.h:72
ldns_buffer_new
ldns_buffer * ldns_buffer_new(size_t capacity)
creates a new buffer with the specified capacity.
Definition buffer.c:16
ldns_buffer_export
void * ldns_buffer_export(ldns_buffer *buffer)
Makes the buffer fixed and returns a pointer to the data.
Definition buffer.c:150
ldns_buffer_set_capacity
signed char ldns_buffer_set_capacity(ldns_buffer *buffer, size_t capacity)
changes the buffer's capacity.
Definition buffer.c:60
ldns_buffer_reserve
signed char ldns_buffer_reserve(ldns_buffer *buffer, size_t amount)
ensures BUFFER can contain at least AMOUNT more bytes.
Definition buffer.c:80
ldns_buffer_printf
int ldns_buffer_printf(ldns_buffer *buffer, const char *format,...)
prints to the buffer, increasing the capacity if required using buffer_reserve().
Definition buffer.c:99
config.h
ldns_b64_ntop
int ldns_b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize)
ldns_dname_label
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.
Definition dname.c:560
ldns_nsec3_next_owner
ldns_rdf * ldns_nsec3_next_owner(const ldns_rr *nsec3_rr)
Returns the first label of the next ownername in the NSEC3 chain (ie.
Definition dnssec.c:1348
ldns_nsec_bitmap_covers_type
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.
Definition dnssec.c:1393
LDNS_MAX_KEYLEN
#define LDNS_MAX_KEYLEN
Definition dnssec.h:41
ldns_calc_keytag
uint16_t ldns_calc_keytag(const ldns_rr *key)
calculates a keytag of a key for use in DNSSEC.
Definition dnssec.c:277
ldns_nsec3_optout
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.
Definition dnssec.c:1286
ldns_nsec_bitmap_set_type
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.
Definition dnssec.c:1430
ldns_nsec_bitmap_clear_type
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.
Definition dnssec.c:1468
ldns_dnssec_name_name
ldns_rdf * ldns_dnssec_name_name(const ldns_dnssec_name *name)
Returns the domain name of the given dnssec_name structure.
Definition dnssec_zone.c:395
ldns_dnssec_name
struct ldns_struct_dnssec_name ldns_dnssec_name
Structure containing all resource records for a domain name Including the derived NSEC3,...
Definition dnssec_zone.h:44
LDNS_EDE_DNSSEC_INDETERMINATE
@ LDNS_EDE_DNSSEC_INDETERMINATE
Definition edns.h:58
LDNS_EDE_NOT_SUPPORTED
@ LDNS_EDE_NOT_SUPPORTED
Definition edns.h:74
LDNS_EDE_PROHIBITED
@ LDNS_EDE_PROHIBITED
Definition edns.h:71
LDNS_EDE_NOT_READY
@ LDNS_EDE_NOT_READY
Definition edns.h:67
LDNS_EDE_UNSUPPORTED_DNSKEY_ALG
@ LDNS_EDE_UNSUPPORTED_DNSKEY_ALG
Definition edns.h:54
LDNS_EDE_RRSIGS_MISSING
@ LDNS_EDE_RRSIGS_MISSING
Definition edns.h:63
LDNS_EDE_NO_REACHABLE_AUTHORITY
@ LDNS_EDE_NO_REACHABLE_AUTHORITY
Definition edns.h:75
LDNS_EDE_SIGNATURE_EXPIRED
@ LDNS_EDE_SIGNATURE_EXPIRED
Definition edns.h:60
LDNS_EDE_DNSSEC_BOGUS
@ LDNS_EDE_DNSSEC_BOGUS
Definition edns.h:59
LDNS_EDE_CENSORED
@ LDNS_EDE_CENSORED
Definition edns.h:69
LDNS_EDE_STALE_NXDOMAIN_ANSWER
@ LDNS_EDE_STALE_NXDOMAIN_ANSWER
Definition edns.h:72
LDNS_EDE_NO_ZONE_KEY_BIT_SET
@ LDNS_EDE_NO_ZONE_KEY_BIT_SET
Definition edns.h:64
LDNS_EDE_DNSKEY_MISSING
@ LDNS_EDE_DNSKEY_MISSING
Definition edns.h:62
LDNS_EDE_NETWORK_ERROR
@ LDNS_EDE_NETWORK_ERROR
Definition edns.h:76
LDNS_EDE_FILTERED
@ LDNS_EDE_FILTERED
Definition edns.h:70
LDNS_EDE_BLOCKED
@ LDNS_EDE_BLOCKED
Definition edns.h:68
LDNS_EDE_FORGED_ANSWER
@ LDNS_EDE_FORGED_ANSWER
Definition edns.h:57
LDNS_EDE_SIGNATURE_EXPIRED_BEFORE_VALID
@ LDNS_EDE_SIGNATURE_EXPIRED_BEFORE_VALID
Definition edns.h:78
LDNS_EDE_STALE_ANSWER
@ LDNS_EDE_STALE_ANSWER
Definition edns.h:56
LDNS_EDE_NOT_AUTHORITATIVE
@ LDNS_EDE_NOT_AUTHORITATIVE
Definition edns.h:73
LDNS_EDE_CACHED_ERROR
@ LDNS_EDE_CACHED_ERROR
Definition edns.h:66
LDNS_EDE_NSEC_MISSING
@ LDNS_EDE_NSEC_MISSING
Definition edns.h:65
LDNS_EDE_OTHER
@ LDNS_EDE_OTHER
Definition edns.h:53
LDNS_EDE_INVALID_DATA
@ LDNS_EDE_INVALID_DATA
Definition edns.h:77
LDNS_EDE_SIGNATURE_NOT_YET_VALID
@ LDNS_EDE_SIGNATURE_NOT_YET_VALID
Definition edns.h:61
LDNS_EDE_UNSUPPORTED_DS_DIGEST
@ LDNS_EDE_UNSUPPORTED_DS_DIGEST
Definition edns.h:55
LDNS_EDE_TOO_EARLY
@ LDNS_EDE_TOO_EARLY
Definition edns.h:79
ldns_edns_option_code
enum ldns_enum_edns_option ldns_edns_option_code
Definition edns.h:46
ldns_edns_get_data
uint8_t * ldns_edns_get_data(const ldns_edns_option *edns)
returns the EDNS option data.
Definition edns.c:39
ldns_edns_option_list
struct ldns_struct_edns_option_list ldns_edns_option_list
Definition edns.h:115
ldns_edns_get_code
ldns_edns_option_code ldns_edns_get_code(const ldns_edns_option *edns)
returns the option code of the EDNS data.
Definition edns.c:32
ldns_edns_option_list_deep_free
void ldns_edns_option_list_deep_free(ldns_edns_option_list *options_list)
Definition edns.c:264
ldns_edns_option
struct ldns_struct_edns_option ldns_edns_option
Definition edns.h:102
ldns_edns_get_size
size_t ldns_edns_get_size(const ldns_edns_option *edns)
returns the size of the EDNS data.
Definition edns.c:25
ldns_edns_option_list_get_option
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.
Definition edns.c:287
ldns_edns_option_list_get_count
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.
Definition edns.c:277
LDNS_EDNS_NSID
@ LDNS_EDNS_NSID
Definition edns.h:30
LDNS_EDNS_KEEPALIVE
@ LDNS_EDNS_KEEPALIVE
Definition edns.h:38
LDNS_EDNS_DHU
@ LDNS_EDNS_DHU
Definition edns.h:33
LDNS_EDNS_PADDING
@ LDNS_EDNS_PADDING
Definition edns.h:39
LDNS_EDNS_COOKIE
@ LDNS_EDNS_COOKIE
Definition edns.h:37
LDNS_EDNS_DAU
@ LDNS_EDNS_DAU
Definition edns.h:32
LDNS_EDNS_N3U
@ LDNS_EDNS_N3U
Definition edns.h:34
LDNS_EDNS_UL
@ LDNS_EDNS_UL
Definition edns.h:29
LDNS_EDNS_CLIENT_SUBNET
@ LDNS_EDNS_CLIENT_SUBNET
Definition edns.h:35
LDNS_EDNS_KEY_TAG
@ LDNS_EDNS_KEY_TAG
Definition edns.h:41
LDNS_EDNS_CHAIN
@ LDNS_EDNS_CHAIN
Definition edns.h:40
LDNS_EDNS_CLIENT_TAG
@ LDNS_EDNS_CLIENT_TAG
Definition edns.h:43
LDNS_EDNS_EDE
@ LDNS_EDNS_EDE
Definition edns.h:42
LDNS_EDNS_LLQ
@ LDNS_EDNS_LLQ
Definition edns.h:28
LDNS_EDNS_SERVER_TAG
@ LDNS_EDNS_SERVER_TAG
Definition edns.h:44
LDNS_EDNS_EXPIRE
@ LDNS_EDNS_EXPIRE
Definition edns.h:36
LDNS_STATUS_WIRE_RDATA_ERR
@ LDNS_STATUS_WIRE_RDATA_ERR
Definition error.h:125
LDNS_STATUS_NO_SVCPARAM_VALUE_EXPECTED
@ LDNS_STATUS_NO_SVCPARAM_VALUE_EXPECTED
Definition error.h:142
LDNS_STATUS_NULL
@ LDNS_STATUS_NULL
Definition error.h:51
LDNS_STATUS_ERR
@ LDNS_STATUS_ERR
Definition error.h:37
LDNS_STATUS_MEM_ERR
@ LDNS_STATUS_MEM_ERR
Definition error.h:34
LDNS_STATUS_INVALID_SVCPARAM_VALUE
@ LDNS_STATUS_INVALID_SVCPARAM_VALUE
Definition error.h:144
LDNS_STATUS_OK
@ LDNS_STATUS_OK
Definition error.h:26
LDNS_STATUS_DOMAINNAME_OVERFLOW
@ LDNS_STATUS_DOMAINNAME_OVERFLOW
Definition error.h:29
LDNS_STATUS_RDATA_OVERFLOW
@ LDNS_STATUS_RDATA_OVERFLOW
Definition error.h:129
LDNS_STATUS_NOT_IMPL
@ LDNS_STATUS_NOT_IMPL
Definition error.h:50
ldns_status
enum ldns_enum_status ldns_status
Definition error.h:148
ldns_pkt2str_fmt
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 *.
Definition host2str.c:3317
ldns_rr2buffer_str
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...
Definition host2str.c:2033
ldns_rdf2buffer_str_hip
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,...
Definition host2str.c:1265
ldns_rdf2buffer_str_wks
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.
Definition host2str.c:817
pkt_edns_data2edns_option_list
ldns_edns_option_list * pkt_edns_data2edns_option_list(const ldns_rdf *edns_data)
Definition packet.c:764
ldns_key2str
char * ldns_key2str(const ldns_key *k)
Converts a private key to the test presentation fmt and returns that as a char *.
Definition host2str.c:3342
ldns_pkt_cert_algorithm2str
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.
Definition host2str.c:314
ldns_key2buffer_str
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...
Definition host2str.c:2961
ldns_rdf2buffer_str_int32
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.
Definition host2str.c:405
ldns_edns_option_list2buffer_str
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...
Definition host2str.c:2609
ldns_rdf2buffer_str_hex
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.
Definition host2str.c:530
ldns_pkt_opcode2str
char * ldns_pkt_opcode2str(ldns_pkt_opcode opcode)
Converts a packet opcode to its mnemonic and returns that as an allocated null-terminated string.
Definition host2str.c:253
ldns_rdf2buffer_str_str
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.
Definition host2str.c:471
ldns_pkt_rcode2buffer_str
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.
Definition host2str.c:212
ldns_rr2str
char * ldns_rr2str(const ldns_rr *rr)
Converts the data in the resource record to presentation format and returns that as a char *.
Definition host2str.c:3311
ldns_rdf2buffer_str_loc
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.
Definition host2str.c:705
ldns_rdf2buffer_str_apl
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.
Definition host2str.c:973
ldns_rdf2buffer_str_nsap
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.
Definition host2str.c:804
ldns_rr_list_print_fmt
void ldns_rr_list_print_fmt(FILE *output, const ldns_output_format *fmt, const ldns_rr_list *lst)
print a rr_list to output
Definition host2str.c:3444
ldns_rdf2buffer_str_b64
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.
Definition host2str.c:487
ldns_rdf2buffer_str_type
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.
Definition host2str.c:558
ldns_buffer_export2str
char * ldns_buffer_export2str(ldns_buffer *buffer)
Exports and returns the data in the buffer as a null terminated char * string.
Definition host2str.c:3262
ldns_rdf2buffer_str
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...
Definition host2str.c:1751
ldns_pkt_print_fmt
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).
Definition host2str.c:3425
ldns_pkt2str
char * ldns_pkt2str(const ldns_pkt *pkt)
Converts the data in the DNS packet to presentation format and returns that as a char *.
Definition host2str.c:3336
ldns_rr_list2str_fmt
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 *.
Definition host2str.c:3359
ldns_pkt2buffer_str_fmt
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...
Definition host2str.c:2689
ldns_buffer2str
char * ldns_buffer2str(ldns_buffer *buffer)
Returns a copy of the data in the buffer as a null terminated char * string.
Definition host2str.c:3235
ldns_rr_type2str
char * ldns_rr_type2str(const ldns_rr_type type)
Converts an ldns_rr_type value to its string representation, and returns that string.
Definition host2str.c:650
ldns_rr2buffer_str_fmt
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...
Definition host2str.c:1809
ldns_output_format_nocomments_record
const ldns_output_format ldns_output_format_nocomments_record
Definition host2str.c:133
ldns_zone_print_fmt
void ldns_zone_print_fmt(FILE *output, const ldns_output_format *fmt, const ldns_zone *z)
Print a zone structure * to output.
Definition host2str.c:3533
ldns_pktheader2buffer_str
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.
Definition host2str.c:2059
ldns_rdf2buffer_str_tag
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...
Definition host2str.c:1228
ldns_output_format_onlykeyids_record
const ldns_output_format ldns_output_format_onlykeyids_record
Definition host2str.c:136
ldns_rr_list2buffer_str
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.
Definition host2str.c:2052
ldns_rr_class2str
char * ldns_rr_class2str(const ldns_rr_class klass)
Converts an ldns_rr_class value to its string representation, and returns that string.
Definition host2str.c:686
ldns_rr_class2buffer_str
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.
Definition host2str.c:671
ldns_rdf_print
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).
Definition host2str.c:3394
ldns_pkt_rcode2str
char * ldns_pkt_rcode2str(ldns_pkt_rcode rcode)
Converts a packet rcode to its mnemonic and returns that as an allocated null-terminated string.
Definition host2str.c:273
ldns_algorithm2buffer_str
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.
Definition host2str.c:224
ldns_rdf2buffer_str_time
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.
Definition host2str.c:413
ldns_rr_print
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).
Definition host2str.c:3419
svcparam_key2buffer_str
ldns_status svcparam_key2buffer_str(ldns_buffer *output, uint16_t key)
Definition str2host.c:2201
ldns_cert_algorithm2buffer_str
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.
Definition host2str.c:238
INET_ADDRSTRLEN
#define INET_ADDRSTRLEN
Definition host2str.c:40
ldns_resolver_print_fmt
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.
Definition host2str.c:3460
ldns_rdf2str
char * ldns_rdf2str(const ldns_rdf *rdf)
Converts the data in the rdata field to presentation format and returns that as a char *.
Definition host2str.c:3276
ldns_rdf2buffer_str_tsigtime
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.
Definition host2str.c:949
ldns_rdf2buffer_str_eui48
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...
Definition host2str.c:1201
ldns_rdf2buffer_str_int8
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.
Definition host2str.c:389
ldns_rdf2buffer_str_alg
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.
Definition host2str.c:594
ldns_rdf2buffer_str_svcparams
ldns_status ldns_rdf2buffer_str_svcparams(ldns_buffer *output, const ldns_rdf *rdf)
Converts an LDNS_RDF_TYPE_SVCPARAMS rdata element to presentation format.
Definition host2str.c:1551
ldns_rdf2buffer_str_eui64
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...
Definition host2str.c:1214
ldns_rdf2buffer_str_amtrelay
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,...
Definition host2str.c:1309
ldns_rdf2buffer_str_ilnp64
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 ...
Definition host2str.c:1187
ldns_rdf2buffer_str_nsec
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.
Definition host2str.c:906
ldns_resolver_print
void ldns_resolver_print(FILE *output, const ldns_resolver *r)
Print a resolver (in sofar that is possible) state to output.
Definition host2str.c:3527
ldns_rdf2buffer_str_long_str
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...
Definition host2str.c:1254
ldns_output_format_clear_type
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.
Definition host2str.c:180
ldns_rdf2buffer_str_b32_ext
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.
Definition host2str.c:509
ldns_rr2str_fmt
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 *.
Definition host2str.c:3293
ldns_rdf2buffer_str_unknown
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.
Definition host2str.c:797
ldns_zone_print
void ldns_zone_print(FILE *output, const ldns_zone *z)
Print a zone structure * to output.
Definition host2str.c:3541
ldns_rdf2buffer_str_cert_alg
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.
Definition host2str.c:580
ldns_rr_list_print
void ldns_rr_list_print(FILE *output, const ldns_rr_list *lst)
print a rr_list to output
Definition host2str.c:3454
ldns_rdf2buffer_str_class
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.
Definition host2str.c:565
ldns_rdf2buffer_str_int16
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.
Definition host2str.c:397
ldns_rr_list2str
char * ldns_rr_list2str(const ldns_rr_list *list)
Converts a list of resource records to presentation format and returns that as a char *.
Definition host2str.c:3388
ldns_rdf2buffer_str_ipseckey
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.
Definition host2str.c:1077
ldns_pkt_opcode2buffer_str
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.
Definition host2str.c:200
ldns_rdf2buffer_str_period
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.
Definition host2str.c:938
ldns_pkt_print
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).
Definition host2str.c:3438
ldns_rr_list2buffer_str_fmt
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.
Definition host2str.c:2039
ldns_rdf2buffer_str_dname
ldns_status ldns_rdf2buffer_str_dname(ldns_buffer *output, const ldns_rdf *dname)
Print the ldns_rdf containing a dname to the buffer.
Definition host2str.c:337
ldns_hashes
ldns_lookup_table ldns_hashes[]
Definition host2str.c:75
ldns_rdf2buffer_str_a
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.
Definition host2str.c:428
ldns_output_format_set_type
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.
Definition host2str.c:160
ldns_rdf2buffer_str_nsec3_salt
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.
Definition host2str.c:913
ldns_output_format_bubblebabble_record
const ldns_output_format ldns_output_format_bubblebabble_record
Definition host2str.c:144
ldns_rr_type2buffer_str
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.
Definition host2str.c:617
ldns_pkt2buffer_str
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...
Definition host2str.c:2825
ldns_pkt_algorithm2str
char * ldns_pkt_algorithm2str(ldns_algorithm algorithm)
Converts a signing algorithms to its mnemonic and returns that as an allocated null-terminated string...
Definition host2str.c:293
INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN
Definition host2str.c:43
ldns_rdf2buffer_str_int16_data
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.
Definition host2str.c:1050
ldns_rdf2buffer_str_aaaa
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.
Definition host2str.c:439
ldns_rdf2buffer_str_atma
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.
Definition host2str.c:811
ldns_rr_print_fmt
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).
Definition host2str.c:3406
LDNS_COMMENT_KEY_SIZE
#define LDNS_COMMENT_KEY_SIZE
Show DNSKEY key size as comment.
Definition host2str.h:54
LDNS_APL_IP4
#define LDNS_APL_IP4
Definition host2str.h:37
ldns_output_format_nocomments
const ldns_output_format * ldns_output_format_nocomments
Standard output format record that disables commenting in the textual representation of Resource Reco...
Definition host2str.c:135
LDNS_COMMENT_RRSIGS
#define LDNS_COMMENT_RRSIGS
Also comment KEY_ID with RRSIGS.
Definition host2str.h:64
LDNS_APL_MASK
#define LDNS_APL_MASK
Definition host2str.h:39
LDNS_FMT_PAD_SOA_SERIAL
#define LDNS_FMT_PAD_SOA_SERIAL
Definition host2str.h:66
LDNS_COMMENT_BUBBLEBABBLE
#define LDNS_COMMENT_BUBBLEBABBLE
Provide bubblebabble representation for DS RR's as comment.
Definition host2str.h:56
ldns_output_format_onlykeyids
const ldns_output_format * ldns_output_format_onlykeyids
Standard output format record that annotated only DNSKEY RR's with comment text.
Definition host2str.c:140
LDNS_FMT_ZEROIZE_RRSIGS
#define LDNS_FMT_ZEROIZE_RRSIGS
Definition host2str.h:65
LDNS_FMT_RFC3597
#define LDNS_FMT_RFC3597
Definition host2str.h:67
LDNS_COMMENT_FLAGS
#define LDNS_COMMENT_FLAGS
Show when a NSEC3 RR has the optout flag set as comment.
Definition host2str.h:58
ldns_output_format_storage
struct ldns_struct_output_format_storage ldns_output_format_storage
Definition host2str.h:107
LDNS_APL_IP6
#define LDNS_APL_IP6
Definition host2str.h:38
LDNS_COMMENT_NULLS
#define LDNS_COMMENT_NULLS
Represent a NULL pointer (instead of a pointer to a ldns_rr as "; (null)" as opposed to outputting no...
Definition host2str.h:48
LDNS_COMMENT_KEY_ID
#define LDNS_COMMENT_KEY_ID
Show key id with DNSKEY RR's as comment.
Definition host2str.h:50
LDNS_APL_NEGATION
#define LDNS_APL_NEGATION
Definition host2str.h:40
LDNS_FMT_SHORT
#define LDNS_FMT_SHORT
Prints only answer section of packets and only rdata of RRs.
Definition host2str.h:69
ldns_output_format_default
const ldns_output_format * ldns_output_format_default
The default output format record.
Definition host2str.c:142
LDNS_COMMENT_KEY_TYPE
#define LDNS_COMMENT_KEY_TYPE
Show if a DNSKEY is a ZSK or KSK as comment.
Definition host2str.h:52
LDNS_COMMENT_KEY
#define LDNS_COMMENT_KEY
Show key id, type and size as comment for DNSKEY RR's.
Definition host2str.h:74
ldns_output_format_bubblebabble
const ldns_output_format * ldns_output_format_bubblebabble
Standard output format record that shows all DNSKEY related information in the comment text,...
Definition host2str.c:148
LDNS_COMMENT_NSEC3_CHAIN
#define LDNS_COMMENT_NSEC3_CHAIN
Show the unhashed owner and next owner names for NSEC3 RR's as comment.
Definition host2str.h:60
ldns_output_format
struct ldns_struct_output_format ldns_output_format
Definition host2str.h:95
ldns_key_rsa_key
RSA * ldns_key_rsa_key(const ldns_key *k)
returns the (openssl) RSA struct contained in the key
Definition keys.c:1494
LDNS_KEY_SEP_KEY
#define LDNS_KEY_SEP_KEY
Definition keys.h:38
LDNS_ED448
@ LDNS_ED448
Definition keys.h:59
LDNS_RSAMD5
@ LDNS_RSAMD5
Definition keys.h:46
LDNS_ECDSAP384SHA384
@ LDNS_ECDSAP384SHA384
Definition keys.h:57
LDNS_RSASHA1_NSEC3
@ LDNS_RSASHA1_NSEC3
Definition keys.h:52
LDNS_DSA_NSEC3
@ LDNS_DSA_NSEC3
Definition keys.h:51
LDNS_DSA
@ LDNS_DSA
Definition keys.h:48
LDNS_ECDSAP256SHA256
@ LDNS_ECDSAP256SHA256
Definition keys.h:56
LDNS_ECC_GOST
@ LDNS_ECC_GOST
Definition keys.h:55
LDNS_PRIVATEOID
@ LDNS_PRIVATEOID
Definition keys.h:62
LDNS_PRIVATEDNS
@ LDNS_PRIVATEDNS
Definition keys.h:61
LDNS_DH
@ LDNS_DH
Definition keys.h:47
LDNS_INDIRECT
@ LDNS_INDIRECT
Definition keys.h:60
LDNS_ECC
@ LDNS_ECC
Definition keys.h:49
LDNS_RSASHA1
@ LDNS_RSASHA1
Definition keys.h:50
LDNS_RSASHA512
@ LDNS_RSASHA512
Definition keys.h:54
LDNS_RSASHA256
@ LDNS_RSASHA256
Definition keys.h:53
LDNS_ED25519
@ LDNS_ED25519
Definition keys.h:58
ldns_key
struct ldns_struct_key ldns_key
Definition keys.h:167
ldns_key_hmac_size
size_t ldns_key_hmac_size(const ldns_key *k)
return the hmac key size
Definition keys.c:1531
ldns_key_dsa_key
DSA * ldns_key_dsa_key(const ldns_key *k)
returns the (openssl) DSA struct contained in the key
Definition keys.c:1504
ldns_key_algorithm
ldns_signing_algorithm ldns_key_algorithm(const ldns_key *k)
return the signing alg of the key
Definition keys.c:1463
LDNS_SIGN_RSASHA1
@ LDNS_SIGN_RSASHA1
Definition keys.h:84
LDNS_SIGN_ECDSAP256SHA256
@ LDNS_SIGN_ECDSAP256SHA256
Definition keys.h:95
LDNS_SIGN_DSA_NSEC3
@ LDNS_SIGN_DSA_NSEC3
Definition keys.h:92
LDNS_SIGN_ECC_GOST
@ LDNS_SIGN_ECC_GOST
Definition keys.h:94
LDNS_SIGN_ED448
@ LDNS_SIGN_ED448
Definition keys.h:101
LDNS_SIGN_ED25519
@ LDNS_SIGN_ED25519
Definition keys.h:98
LDNS_SIGN_RSASHA1_NSEC3
@ LDNS_SIGN_RSASHA1_NSEC3
Definition keys.h:88
LDNS_SIGN_HMACSHA224
@ LDNS_SIGN_HMACSHA224
Definition keys.h:106
LDNS_SIGN_ECDSAP384SHA384
@ LDNS_SIGN_ECDSAP384SHA384
Definition keys.h:96
LDNS_SIGN_HMACMD5
@ LDNS_SIGN_HMACMD5
Definition keys.h:103
LDNS_SIGN_RSAMD5
@ LDNS_SIGN_RSAMD5
Definition keys.h:83
LDNS_SIGN_RSASHA512
@ LDNS_SIGN_RSASHA512
Definition keys.h:90
LDNS_SIGN_DSA
@ LDNS_SIGN_DSA
Definition keys.h:86
LDNS_SIGN_RSASHA256
@ LDNS_SIGN_RSASHA256
Definition keys.h:89
LDNS_SIGN_HMACSHA384
@ LDNS_SIGN_HMACSHA384
Definition keys.h:107
LDNS_SIGN_HMACSHA1
@ LDNS_SIGN_HMACSHA1
Definition keys.h:104
LDNS_SIGN_HMACSHA512
@ LDNS_SIGN_HMACSHA512
Definition keys.h:108
LDNS_SIGN_HMACSHA256
@ LDNS_SIGN_HMACSHA256
Definition keys.h:105
ldns_key_hmac_key
unsigned char * ldns_key_hmac_key(const ldns_key *k)
return the hmac key data
Definition keys.c:1521
LDNS_HASH_GOST
@ LDNS_HASH_GOST
Definition keys.h:73
LDNS_SHA256
@ LDNS_SHA256
Definition keys.h:72
LDNS_SHA1
@ LDNS_SHA1
Definition keys.h:71
LDNS_SHA384
@ LDNS_SHA384
Definition keys.h:74
LDNS_KEY_ZONE_KEY
#define LDNS_KEY_ZONE_KEY
Definition keys.h:37
ldns_algorithm
enum ldns_enum_algorithm ldns_algorithm
Definition keys.h:64
ldns_rcodes
ldns_lookup_table ldns_rcodes[]
Response codes.
Definition host2str.c:109
ldns_algorithms
ldns_lookup_table ldns_algorithms[]
Taken from RFC 2535, section 7.
Definition host2str.c:53
ldns_opcodes
ldns_lookup_table ldns_opcodes[]
Operation codes.
Definition host2str.c:124
ldns_rr_classes
ldns_lookup_table ldns_rr_classes[]
rr types
Definition host2str.c:99
LDNS_IP4ADDRLEN
#define LDNS_IP4ADDRLEN
Definition ldns.h:132
LDNS_IP6ADDRLEN
#define LDNS_IP6ADDRLEN
Definition ldns.h:133
ldns_cert_algorithms
ldns_lookup_table ldns_cert_algorithms[]
Taken from RFC 2538.
Definition host2str.c:84
LDNS_MAX_PACKETLEN
#define LDNS_MAX_PACKETLEN
Definition packet.h:24
ldns_pkt_edns
signed char ldns_pkt_edns(const ldns_pkt *packet)
returns true if this packet needs and EDNS rr to be sent.
Definition packet.c:750
ldns_pkt_edns_version
uint8_t ldns_pkt_edns_version(const ldns_pkt *packet)
return the packet's edns version
Definition packet.c:219
ldns_pkt_aa
signed char ldns_pkt_aa(const ldns_pkt *p)
Read the packet's aa bit.
Definition packet.c:52
ldns_pkt_size
size_t ldns_pkt_size(const ldns_pkt *p)
Return the packet's size in bytes.
Definition packet.c:183
ldns_pkt_additional
ldns_rr_list * ldns_pkt_additional(const ldns_pkt *p)
Return the packet's additional section.
Definition packet.c:142
ldns_pkt_authority
ldns_rr_list * ldns_pkt_authority(const ldns_pkt *p)
Return the packet's authority section.
Definition packet.c:136
ldns_pkt_answerfrom
ldns_rdf * ldns_pkt_answerfrom(const ldns_pkt *p)
Return the packet's answerfrom.
Definition packet.c:195
ldns_pkt_querytime
uint32_t ldns_pkt_querytime(const ldns_pkt *p)
Return the packet's querytime.
Definition packet.c:189
ldns_pkt_question
ldns_rr_list * ldns_pkt_question(const ldns_pkt *p)
Return the packet's question section.
Definition packet.c:124
ldns_pkt_ancount
uint16_t ldns_pkt_ancount(const ldns_pkt *p)
Return the packet's an count.
Definition packet.c:106
ldns_pkt_nscount
uint16_t ldns_pkt_nscount(const ldns_pkt *p)
Return the packet's ns count.
Definition packet.c:112
ldns_pkt_rcode
enum ldns_enum_pkt_rcode ldns_pkt_rcode
Definition packet.h:69
ldns_pkt_answer
ldns_rr_list * ldns_pkt_answer(const ldns_pkt *p)
Return the packet's answer section.
Definition packet.c:130
ldns_pkt
struct ldns_struct_pkt ldns_pkt
Definition packet.h:272
ldns_pkt_id
uint16_t ldns_pkt_id(const ldns_pkt *p)
Read the packet id.
Definition packet.c:40
LDNS_PACKET_IQUERY
@ LDNS_PACKET_IQUERY
Definition packet.h:48
LDNS_PACKET_NOTIFY
@ LDNS_PACKET_NOTIFY
Definition packet.h:50
LDNS_PACKET_QUERY
@ LDNS_PACKET_QUERY
Definition packet.h:47
LDNS_PACKET_STATUS
@ LDNS_PACKET_STATUS
Definition packet.h:49
LDNS_PACKET_UPDATE
@ LDNS_PACKET_UPDATE
Definition packet.h:51
ldns_pkt_tc
signed char ldns_pkt_tc(const ldns_pkt *p)
Read the packet's tc bit.
Definition packet.c:58
ldns_pkt_ra
signed char ldns_pkt_ra(const ldns_pkt *p)
Read the packet's ra bit.
Definition packet.c:76
ldns_pkt_opcode
enum ldns_enum_pkt_opcode ldns_pkt_opcode
Definition packet.h:53
ldns_pkt_edns_data
ldns_rdf * ldns_pkt_edns_data(const ldns_pkt *packet)
return the packet's EDNS data
Definition packet.c:260
ldns_pkt_edns_extended_rcode
uint8_t ldns_pkt_edns_extended_rcode(const ldns_pkt *packet)
return the packet's edns extended rcode
Definition packet.c:213
ldns_pkt_qdcount
uint16_t ldns_pkt_qdcount(const ldns_pkt *p)
Return the packet's qd count.
Definition packet.c:100
ldns_pkt_cd
signed char ldns_pkt_cd(const ldns_pkt *p)
Read the packet's cd bit.
Definition packet.c:70
ldns_pkt_tsig
ldns_rr * ldns_pkt_tsig(const ldns_pkt *p)
Return the packet's tsig pseudo rr's.
Definition packet.c:465
ldns_pkt_get_opcode
ldns_pkt_opcode ldns_pkt_get_opcode(const ldns_pkt *p)
Read the packet's code.
Definition packet.c:88
ldns_pkt_edns_do
signed char ldns_pkt_edns_do(const ldns_pkt *packet)
return the packet's edns do bit
Definition packet.c:231
ldns_pkt_arcount
uint16_t ldns_pkt_arcount(const ldns_pkt *p)
Return the packet's ar count.
Definition packet.c:118
ldns_pkt_qr
signed char ldns_pkt_qr(const ldns_pkt *p)
Read the packet's qr bit.
Definition packet.c:46
ldns_pkt_timestamp
struct timeval ldns_pkt_timestamp(const ldns_pkt *p)
Return the packet's timestamp.
Definition packet.c:201
ldns_pkt_rd
signed char ldns_pkt_rd(const ldns_pkt *p)
Read the packet's rd bit.
Definition packet.c:64
ldns_pkt_ad
signed char ldns_pkt_ad(const ldns_pkt *p)
Read the packet's ad bit.
Definition packet.c:82
LDNS_RCODE_REFUSED
@ LDNS_RCODE_REFUSED
Definition packet.h:62
LDNS_RCODE_YXDOMAIN
@ LDNS_RCODE_YXDOMAIN
Definition packet.h:63
LDNS_RCODE_FORMERR
@ LDNS_RCODE_FORMERR
Definition packet.h:58
LDNS_RCODE_YXRRSET
@ LDNS_RCODE_YXRRSET
Definition packet.h:64
LDNS_RCODE_SERVFAIL
@ LDNS_RCODE_SERVFAIL
Definition packet.h:59
LDNS_RCODE_NOTIMPL
@ LDNS_RCODE_NOTIMPL
Definition packet.h:61
LDNS_RCODE_NXRRSET
@ LDNS_RCODE_NXRRSET
Definition packet.h:65
LDNS_RCODE_NOTZONE
@ LDNS_RCODE_NOTZONE
Definition packet.h:67
LDNS_RCODE_NXDOMAIN
@ LDNS_RCODE_NXDOMAIN
Definition packet.h:60
LDNS_RCODE_NOTAUTH
@ LDNS_RCODE_NOTAUTH
Definition packet.h:66
LDNS_RCODE_NOERROR
@ LDNS_RCODE_NOERROR
Definition packet.h:57
ldns_pkt_get_rcode
ldns_pkt_rcode ldns_pkt_get_rcode(const ldns_pkt *p)
Return the packet's response code.
Definition packet.c:94
ldns_pkt_edns_udp_size
uint16_t ldns_pkt_edns_udp_size(const ldns_pkt *packet)
return the packet's edns udp size
Definition packet.c:207
ldns_rbtree_search
ldns_rbnode_t * ldns_rbtree_search(ldns_rbtree_t *rbtree, const void *key)
Find key in tree.
Definition rbtree.c:294
ldns_cert_algorithm
enum ldns_enum_cert_algorithm ldns_cert_algorithm
Definition rdata.h:169
ldns_rdf_data
uint8_t * ldns_rdf_data(const ldns_rdf *rd)
returns the data of the rdf.
Definition rdata.c:38
ldns_rdf_get_type
ldns_rdf_type ldns_rdf_get_type(const ldns_rdf *rd)
returns the type of the rdf.
Definition rdata.c:31
ldns_rdf_new_frm_data
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.
Definition rdata.c:193
ldns_rdf_deep_free
void ldns_rdf_deep_free(ldns_rdf *rd)
frees a rdf structure and frees the data.
Definition rdata.c:230
ldns_rdf2native_int32
uint32_t ldns_rdf2native_int32(const ldns_rdf *rd)
returns the native uint32_t representation from the rdf.
Definition rdata.c:98
ldns_rdf2native_int16
uint16_t ldns_rdf2native_int16(const ldns_rdf *rd)
returns the native uint16_t representation from the rdf.
Definition rdata.c:84
ldns_svcparam_key
enum ldns_enum_svcparam_key ldns_svcparam_key
Definition rdata.h:187
LDNS_RDF_TYPE_INT32
@ LDNS_RDF_TYPE_INT32
32 bits
Definition rdata.h:56
LDNS_RDF_TYPE_TAG
@ LDNS_RDF_TYPE_TAG
A non-zero sequence of US-ASCII letters and numbers in lower case.
Definition rdata.h:126
LDNS_RDF_TYPE_NSAP
@ LDNS_RDF_TYPE_NSAP
NSAP.
Definition rdata.h:103
LDNS_RDF_TYPE_HIP
@ LDNS_RDF_TYPE_HIP
Represents the Public Key Algorithm, HIT and Public Key fields for the HIP RR types.
Definition rdata.h:92
LDNS_RDF_TYPE_B32_EXT
@ LDNS_RDF_TYPE_B32_EXT
b32 string
Definition rdata.h:66
LDNS_RDF_TYPE_NSEC3_NEXT_OWNER
@ LDNS_RDF_TYPE_NSEC3_NEXT_OWNER
nsec3 base32 string (with length byte on wire
Definition rdata.h:111
LDNS_RDF_TYPE_CERT_ALG
@ LDNS_RDF_TYPE_CERT_ALG
certificate algorithm
Definition rdata.h:78
LDNS_RDF_TYPE_EUI48
@ LDNS_RDF_TYPE_EUI48
6 * 8 bit hex numbers separated by dashes.
Definition rdata.h:119
LDNS_RDF_TYPE_SERVICE
@ LDNS_RDF_TYPE_SERVICE
protocol and port bitmaps
Definition rdata.h:97
LDNS_RDF_TYPE_EUI64
@ LDNS_RDF_TYPE_EUI64
8 * 8 bit hex numbers separated by dashes.
Definition rdata.h:121
LDNS_RDF_TYPE_PERIOD
@ LDNS_RDF_TYPE_PERIOD
period
Definition rdata.h:86
LDNS_RDF_TYPE_B64
@ LDNS_RDF_TYPE_B64
b64 string
Definition rdata.h:68
LDNS_RDF_TYPE_AAAA
@ LDNS_RDF_TYPE_AAAA
AAAA record.
Definition rdata.h:60
LDNS_RDF_TYPE_UNKNOWN
@ LDNS_RDF_TYPE_UNKNOWN
unknown types
Definition rdata.h:82
LDNS_RDF_TYPE_WKS
@ LDNS_RDF_TYPE_WKS
well known services
Definition rdata.h:101
LDNS_RDF_TYPE_DNAME
@ LDNS_RDF_TYPE_DNAME
domain name
Definition rdata.h:50
LDNS_RDF_TYPE_TIME
@ LDNS_RDF_TYPE_TIME
time (32 bits)
Definition rdata.h:84
LDNS_RDF_TYPE_SVCPARAMS
@ LDNS_RDF_TYPE_SVCPARAMS
draft-ietf-dnsop-svcb-https
Definition rdata.h:146
LDNS_RDF_TYPE_NSEC
@ LDNS_RDF_TYPE_NSEC
nsec type codes
Definition rdata.h:72
LDNS_RDF_TYPE_SELECTOR
@ LDNS_RDF_TYPE_SELECTOR
Definition rdata.h:139
LDNS_RDF_TYPE_NSEC3_SALT
@ LDNS_RDF_TYPE_NSEC3_SALT
nsec3 hash salt
Definition rdata.h:109
LDNS_RDF_TYPE_APL
@ LDNS_RDF_TYPE_APL
apl data
Definition rdata.h:64
LDNS_RDF_TYPE_A
@ LDNS_RDF_TYPE_A
A record.
Definition rdata.h:58
LDNS_RDF_TYPE_LONG_STR
@ LDNS_RDF_TYPE_LONG_STR
A <character-string> encoding of the value field as specified [RFC1035], Section 5....
Definition rdata.h:132
LDNS_RDF_TYPE_LOC
@ LDNS_RDF_TYPE_LOC
location data
Definition rdata.h:99
LDNS_RDF_TYPE_INT16_DATA
@ LDNS_RDF_TYPE_INT16_DATA
variable length any type rdata where the length is specified by the first 2 bytes
Definition rdata.h:95
LDNS_RDF_TYPE_ILNP64
@ LDNS_RDF_TYPE_ILNP64
4 shorts represented as 4 * 16 bit hex numbers separated by colons.
Definition rdata.h:116
LDNS_RDF_TYPE_ATMA
@ LDNS_RDF_TYPE_ATMA
ATMA.
Definition rdata.h:105
LDNS_RDF_TYPE_HEX
@ LDNS_RDF_TYPE_HEX
hex string
Definition rdata.h:70
LDNS_RDF_TYPE_NONE
@ LDNS_RDF_TYPE_NONE
none
Definition rdata.h:48
LDNS_RDF_TYPE_CLASS
@ LDNS_RDF_TYPE_CLASS
a class
Definition rdata.h:76
LDNS_RDF_TYPE_INT8
@ LDNS_RDF_TYPE_INT8
8 bits
Definition rdata.h:52
LDNS_RDF_TYPE_MATCHING_TYPE
@ LDNS_RDF_TYPE_MATCHING_TYPE
Definition rdata.h:140
LDNS_RDF_TYPE_IPSECKEY
@ LDNS_RDF_TYPE_IPSECKEY
IPSECKEY.
Definition rdata.h:107
LDNS_RDF_TYPE_CERTIFICATE_USAGE
@ LDNS_RDF_TYPE_CERTIFICATE_USAGE
Since RFC7218 TLSA records can be given with mnemonics, hence these rdata field types.
Definition rdata.h:138
LDNS_RDF_TYPE_STR
@ LDNS_RDF_TYPE_STR
txt string
Definition rdata.h:62
LDNS_RDF_TYPE_INT16
@ LDNS_RDF_TYPE_INT16
16 bits
Definition rdata.h:54
LDNS_RDF_TYPE_ALG
@ LDNS_RDF_TYPE_ALG
a key algorithm
Definition rdata.h:80
LDNS_RDF_TYPE_AMTRELAY
@ LDNS_RDF_TYPE_AMTRELAY
draft-ietf-mboned-driad-amt-discovery
Definition rdata.h:143
LDNS_RDF_TYPE_TSIGTIME
@ LDNS_RDF_TYPE_TSIGTIME
tsig time 48 bits
Definition rdata.h:88
LDNS_RDF_TYPE_TYPE
@ LDNS_RDF_TYPE_TYPE
a RR type
Definition rdata.h:74
ldns_rdf_size
size_t ldns_rdf_size(const ldns_rdf *rd)
returns the size of the rdf.
Definition rdata.c:24
ldns_rdf
struct ldns_struct_rdf ldns_rdf
Definition rdata.h:205
ldns_rdf_new
ldns_rdf * ldns_rdf_new(ldns_rdf_type type, size_t size, void *data)
allocates a new rdf structure and fills it.
Definition rdata.c:179
LDNS_SVCPARAM_KEY_PORT
@ LDNS_SVCPARAM_KEY_PORT
Definition rdata.h:179
LDNS_SVCPARAM_KEY_ALPN
@ LDNS_SVCPARAM_KEY_ALPN
Definition rdata.h:177
LDNS_SVCPARAM_KEY_ECH
@ LDNS_SVCPARAM_KEY_ECH
Definition rdata.h:181
LDNS_SVCPARAM_KEY_MANDATORY
@ LDNS_SVCPARAM_KEY_MANDATORY
Definition rdata.h:176
LDNS_SVCPARAM_KEY_IPV4HINT
@ LDNS_SVCPARAM_KEY_IPV4HINT
Definition rdata.h:180
LDNS_SVCPARAM_KEY_IPV6HINT
@ LDNS_SVCPARAM_KEY_IPV6HINT
Definition rdata.h:182
LDNS_SVCPARAM_KEY_NO_DEFAULT_ALPN
@ LDNS_SVCPARAM_KEY_NO_DEFAULT_ALPN
Definition rdata.h:178
LDNS_CERT_SPKI
@ LDNS_CERT_SPKI
Definition rdata.h:159
LDNS_CERT_URI
@ LDNS_CERT_URI
Definition rdata.h:166
LDNS_CERT_ISPKI
@ LDNS_CERT_ISPKI
Definition rdata.h:162
LDNS_CERT_IPGP
@ LDNS_CERT_IPGP
Definition rdata.h:163
LDNS_CERT_ACPKIX
@ LDNS_CERT_ACPKIX
Definition rdata.h:164
LDNS_CERT_IACPKIX
@ LDNS_CERT_IACPKIX
Definition rdata.h:165
LDNS_CERT_IPKIX
@ LDNS_CERT_IPKIX
Definition rdata.h:161
LDNS_CERT_OID
@ LDNS_CERT_OID
Definition rdata.h:167
LDNS_CERT_PGP
@ LDNS_CERT_PGP
Definition rdata.h:160
LDNS_CERT_PKIX
@ LDNS_CERT_PKIX
Definition rdata.h:158
ldns_resolver_rtt
size_t * ldns_resolver_rtt(const ldns_resolver *r)
Return the used round trip times for the nameservers.
Definition resolver.c:177
ldns_resolver_dnssec_anchors
ldns_rr_list * ldns_resolver_dnssec_anchors(const ldns_resolver *r)
Get the resolver's DNSSEC anchors.
Definition resolver.c:132
LDNS_RESOLV_RTT_MIN
#define LDNS_RESOLV_RTT_MIN
Definition resolver.h:54
ldns_resolver_dnssec_cd
signed char ldns_resolver_dnssec_cd(const ldns_resolver *r)
Does the resolver set the CD bit.
Definition resolver.c:126
ldns_resolver_fail
signed char ldns_resolver_fail(const ldns_resolver *r)
Does the resolver only try the first nameserver.
Definition resolver.c:84
ldns_resolver_searchlist
ldns_rdf ** ldns_resolver_searchlist(const ldns_resolver *r)
What is the searchlist as used by the resolver.
Definition resolver.c:102
LDNS_RESOLV_RTT_INF
#define LDNS_RESOLV_RTT_INF
Definition resolver.h:53
ldns_resolver_recursive
signed char ldns_resolver_recursive(const ldns_resolver *r)
Is the resolver set to recurse.
Definition resolver.c:66
ldns_resolver_searchlist_count
size_t ldns_resolver_searchlist_count(const ldns_resolver *r)
Return the resolver's searchlist count.
Definition resolver.c:231
ldns_resolver_tsig_keyname
const char * ldns_resolver_tsig_keyname(const ldns_resolver *r)
Return the tsig keyname as used by the nameserver.
Definition resolver.c:207
ldns_resolver_dnsrch
signed char ldns_resolver_dnsrch(const ldns_resolver *r)
Does the resolver apply search list.
Definition resolver.c:78
ldns_resolver_fallback
signed char ldns_resolver_fallback(const ldns_resolver *r)
Get the truncation fallback status.
Definition resolver.c:54
ldns_resolver_nameserver_count
size_t ldns_resolver_nameserver_count(const ldns_resolver *r)
How many nameserver are configured in the resolver.
Definition resolver.c:114
ldns_resolver_nameservers
ldns_rdf ** ldns_resolver_nameservers(const ldns_resolver *r)
Return the configured nameserver ip address.
Definition resolver.c:108
ldns_resolver_retrans
uint8_t ldns_resolver_retrans(const ldns_resolver *r)
Get the retransmit interval.
Definition resolver.c:48
ldns_resolver
struct ldns_struct_resolver ldns_resolver
Definition resolver.h:147
ldns_resolver_domain
ldns_rdf * ldns_resolver_domain(const ldns_resolver *r)
What is the default dname to add to relative queries.
Definition resolver.c:96
ldns_resolver_defnames
signed char ldns_resolver_defnames(const ldns_resolver *r)
Does the resolver apply default domain name.
Definition resolver.c:90
ldns_resolver_edns_udp_size
uint16_t ldns_resolver_edns_udp_size(const ldns_resolver *r)
Get the resolver's udp size.
Definition resolver.c:36
ldns_resolver_dnssec
signed char ldns_resolver_dnssec(const ldns_resolver *r)
Does the resolver do DNSSEC.
Definition resolver.c:120
ldns_resolver_timeout
struct timeval ldns_resolver_timeout(const ldns_resolver *r)
What is the timeout on socket connections.
Definition resolver.c:201
ldns_resolver_ip6
uint8_t ldns_resolver_ip6(const ldns_resolver *r)
Does the resolver use ip6 or ip4.
Definition resolver.c:60
ldns_resolver_random
signed char ldns_resolver_random(const ldns_resolver *r)
Does the resolver randomize the nameserver before usage.
Definition resolver.c:225
ldns_resolver_retry
uint8_t ldns_resolver_retry(const ldns_resolver *r)
Get the number of retries.
Definition resolver.c:42
ldns_resolver_usevc
signed char ldns_resolver_usevc(const ldns_resolver *r)
Does the resolver use tcp or udp.
Definition resolver.c:171
ldns_resolver_igntc
signed char ldns_resolver_igntc(const ldns_resolver *r)
Does the resolver ignore the TC bit (truncated).
Definition resolver.c:165
ldns_resolver_tsig_algorithm
const char * ldns_resolver_tsig_algorithm(const ldns_resolver *r)
Return the tsig algorithm as used by the nameserver.
Definition resolver.c:213
ldns_resolver_port
uint16_t ldns_resolver_port(const ldns_resolver *r)
Get the port the resolver should use.
Definition resolver.c:24
ldns_resolver_debug
signed char ldns_resolver_debug(const ldns_resolver *r)
Get the debug status of the resolver.
Definition resolver.c:72
ldns_rr_ttl
uint32_t ldns_rr_ttl(const ldns_rr *rr)
returns the ttl of an rr structure.
Definition rr.c:935
ldns_rr
struct ldns_struct_rr ldns_rr
Definition rr.h:337
ldns_rr_type
enum ldns_enum_rr_type ldns_rr_type
Definition rr.h:251
LDNS_RR_TYPE_RRSIG
@ LDNS_RR_TYPE_RRSIG
DNSSEC.
Definition rr.h:170
LDNS_RR_TYPE_IXFR
@ LDNS_RR_TYPE_IXFR
Definition rr.h:217
LDNS_RR_TYPE_DNSKEY
@ LDNS_RR_TYPE_DNSKEY
Definition rr.h:172
LDNS_RR_TYPE_SOA
@ LDNS_RR_TYPE_SOA
marks the start of a zone of authority
Definition rr.h:90
LDNS_RR_TYPE_DS
@ LDNS_RR_TYPE_DS
RFC4034, RFC3658.
Definition rr.h:164
LDNS_RR_TYPE_NSEC3
@ LDNS_RR_TYPE_NSEC3
Definition rr.h:176
LDNS_RR_TYPE_MAILA
@ LDNS_RR_TYPE_MAILA
A request for mail agent RRs (Obsolete - see MX).
Definition rr.h:222
LDNS_RR_TYPE_AXFR
@ LDNS_RR_TYPE_AXFR
Definition rr.h:218
LDNS_RR_TYPE_ANY
@ LDNS_RR_TYPE_ANY
any type (wildcard)
Definition rr.h:224
LDNS_RR_TYPE_MAILB
@ LDNS_RR_TYPE_MAILB
A request for mailbox-related records (MB, MG or MR).
Definition rr.h:220
ldns_rr_is_question
signed char ldns_rr_is_question(const ldns_rr *rr)
returns the question flag of an rr structure.
Definition rr.c:929
ldns_rr_rd_count
size_t ldns_rr_rd_count(const ldns_rr *rr)
returns the rd_count of an rr structure.
Definition rr.c:941
ldns_rr_rdf
ldns_rdf * ldns_rr_rdf(const ldns_rr *rr, size_t nr)
returns the rdata field member counter.
Definition rr.c:913
ldns_rr_list_rr_count
size_t ldns_rr_list_rr_count(const ldns_rr_list *rr_list)
returns the number of rr's in an rr_list.
Definition rr.c:961
ldns_rr_get_type
ldns_rr_type ldns_rr_get_type(const ldns_rr *rr)
returns the type of the rr.
Definition rr.c:947
ldns_rr_get_class
ldns_rr_class ldns_rr_get_class(const ldns_rr *rr)
returns the class of the rr.
Definition rr.c:953
ldns_rr_list
struct ldns_struct_rr_list ldns_rr_list
Definition rr.h:351
ldns_rr_class
enum ldns_enum_rr_class ldns_rr_class
Definition rr.h:61
ldns_rr_list_rr
ldns_rr * ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr)
returns a specific rr of an rrlist.
Definition rr.c:994
ldns_rdf_bitmap_known_rr_types_space
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.
Definition rr.c:2629
ldns_rr_owner
ldns_rdf * ldns_rr_owner(const ldns_rr *rr)
returns the owner name of an rr structure.
Definition rr.c:923
LDNS_MAX_DOMAINLEN
#define LDNS_MAX_DOMAINLEN
Maximum length of a complete dname.
Definition rr.h:33
LDNS_RR_CLASS_NONE
@ LDNS_RR_CLASS_NONE
None class, dynamic update.
Definition rr.h:53
LDNS_RR_CLASS_IN
@ LDNS_RR_CLASS_IN
the Internet
Definition rr.h:47
LDNS_RR_CLASS_CH
@ LDNS_RR_CLASS_CH
Chaos class.
Definition rr.h:49
LDNS_RR_CLASS_HS
@ LDNS_RR_CLASS_HS
Hesiod (Dyer 87).
Definition rr.h:51
LDNS_RR_CLASS_ANY
@ LDNS_RR_CLASS_ANY
Any class.
Definition rr.h:55
ldns_rr_descript
const ldns_rr_descriptor * ldns_rr_descript(uint16_t type)
returns the resource record descriptor for the given rr type.
Definition rr.c:2644
ldns_rdf_bitmap_known_rr_types
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.
Definition rr.c:2635
ldns_rr_descriptor
struct ldns_struct_rr_descriptor ldns_rr_descriptor
Definition rr.h:377
ldns_rr_dnskey_key_size
size_t ldns_rr_dnskey_key_size(const ldns_rr *key)
get the length of the keydata in bits
Definition rr_functions.c:344
ldns_str2rdf_dname
ldns_status ldns_str2rdf_dname(ldns_rdf **rd, const char *str)
convert a dname string into wireformat
Definition str2host.c:311
ldns_rbnode_t
The rbnode_t struct definition.
Definition rbtree.h:60
ldns_rbnode_t::data
const void * data
pointer to data
Definition rbtree.h:70
ldns_struct_buffer::_position
size_t _position
The current position used for reading/writing.
Definition buffer.h:53
ldns_struct_key::_key
struct ldns_struct_key::@355255044063357160333161352225065356220123211313 _key
Storage pointers for the types of keys supported.
ldns_struct_key::key
EVP_PKEY * key
Definition keys.h:133
ldns_struct_lookup_table::name
const char * name
Definition util.h:158
ldns_struct_output_format_storage::flags
int flags
Definition host2str.h:103
ldns_struct_output_format_storage::bitmap
ldns_rdf * bitmap
Definition host2str.h:105
ldns_struct_output_format_storage::hashmap
ldns_rbtree_t * hashmap
Definition host2str.h:104
ldns_struct_output_format::flags
int flags
Specification of how RR's should be formatted in text.
Definition host2str.h:91
ldns_struct_pkt::_edns_list
ldns_edns_option_list * _edns_list
Structed EDNS data.
Definition packet.h:262
ldns_struct_rr_descriptor::_name
const char * _name
Textual name of the RR type.
Definition rr.h:363
ldns_serial_arithmetics_gmtime_r
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...
Definition util.c:304
ldns_b32_ntop_extended_hex
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)
Definition util.c:606
LDNS_FREE
#define LDNS_FREE(ptr)
Definition util.h:60
ldns_lookup_by_id
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.
ldns_bubblebabble
char * ldns_bubblebabble(uint8_t *data, size_t len)
Encode data as BubbleBabble.
Definition util.c:430
LDNS_XMALLOC
#define LDNS_XMALLOC(type, count)
Definition util.h:51
ldns_lookup_table
struct ldns_struct_lookup_table ldns_lookup_table
Definition util.h:160
ldns_get_bit
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...
Definition util.c:52
ldns_wire2dname
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.
Definition wire2host.c:56
ldns_zone_soa
ldns_rr * ldns_zone_soa(const ldns_zone *z)
Return the soa record of a zone.
Definition zone.c:17
ldns_zone_rrs
ldns_rr_list * ldns_zone_rrs(const ldns_zone *z)
Get a list of a zone's content.
Definition zone.c:35
ldns_zone
struct ldns_struct_zone ldns_zone
Definition zone.h:50