/build/ldns-qX87Yo/ldns-1.8.4/rdata.c
Go to the documentation of this file.
/*
* rdata.c
*
* rdata implementation
*
* 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>
/*
* Access functions
* do this as functions to get type checking
*/
/* read */
size_t
ldns_rdf_size(const ldns_rdf *rd)
{
assert(rd != NULL);
return rd->_size;
}
ldns_rdf_type
ldns_rdf_get_type(const ldns_rdf *rd)
{
assert(rd != NULL);
return rd->_type;
}
uint8_t *
ldns_rdf_data(const ldns_rdf *rd)
{
assert(rd != NULL);
return rd->_data;
}
/* write */
void
ldns_rdf_set_size(ldns_rdf *rd, size_t size)
{
assert(rd != NULL);
rd->_size = size;
}
void
ldns_rdf_set_type(ldns_rdf *rd, ldns_rdf_type type)
{
assert(rd != NULL);
rd->_type = type;
}
void
ldns_rdf_set_data(ldns_rdf *rd, void *data)
{
/* only copy the pointer */
assert(rd != NULL);
rd->_data = data;
}
/* for types that allow it, return
* the native/host order type */
uint8_t
ldns_rdf2native_int8(const ldns_rdf *rd)
{
uint8_t data;
/* only allow 8 bit rdfs */
if (ldns_rdf_size(rd) != LDNS_RDF_SIZE_BYTE) {
return 0;
}
memcpy(&data, ldns_rdf_data(rd), sizeof(data));
return data;
}
uint16_t
ldns_rdf2native_int16(const ldns_rdf *rd)
{
uint16_t data;
/* only allow 16 bit rdfs */
if (ldns_rdf_size(rd) != LDNS_RDF_SIZE_WORD) {
return 0;
}
memcpy(&data, ldns_rdf_data(rd), sizeof(data));
return ntohs(data);
}
uint32_t
ldns_rdf2native_int32(const ldns_rdf *rd)
{
uint32_t data;
/* only allow 32 bit rdfs */
if (ldns_rdf_size(rd) != LDNS_RDF_SIZE_DOUBLEWORD) {
return 0;
}
memcpy(&data, ldns_rdf_data(rd), sizeof(data));
return ntohl(data);
}
time_t
ldns_rdf2native_time_t(const ldns_rdf *rd)
{
uint32_t data;
/* only allow 32 bit rdfs */
if (ldns_rdf_size(rd) != LDNS_RDF_SIZE_DOUBLEWORD ||
ldns_rdf_get_type(rd) != LDNS_RDF_TYPE_TIME) {
return 0;
}
memcpy(&data, ldns_rdf_data(rd), sizeof(data));
return (time_t)ntohl(data);
}
ldns_rdf *
ldns_native2rdf_int8(ldns_rdf_type type, uint8_t value)
{
return ldns_rdf_new_frm_data(type, LDNS_RDF_SIZE_BYTE, &value);
}
ldns_rdf *
ldns_native2rdf_int16(ldns_rdf_type type, uint16_t value)
{
uint16_t *rdf_data = LDNS_XMALLOC(uint16_t, 1);
ldns_rdf* rdf;
if (!rdf_data) {
return NULL;
}
ldns_write_uint16(rdf_data, value);
rdf = ldns_rdf_new(type, LDNS_RDF_SIZE_WORD, rdf_data);
if(!rdf)
LDNS_FREE(rdf_data);
return rdf;
}
ldns_rdf *
ldns_native2rdf_int32(ldns_rdf_type type, uint32_t value)
{
uint32_t *rdf_data = LDNS_XMALLOC(uint32_t, 1);
ldns_rdf* rdf;
if (!rdf_data) {
return NULL;
}
ldns_write_uint32(rdf_data, value);
rdf = ldns_rdf_new(type, LDNS_RDF_SIZE_DOUBLEWORD, rdf_data);
if(!rdf)
LDNS_FREE(rdf_data);
return rdf;
}
ldns_rdf *
ldns_native2rdf_int16_data(size_t size, uint8_t *data)
{
uint8_t *rdf_data = LDNS_XMALLOC(uint8_t, size + 2);
ldns_rdf* rdf;
if (!rdf_data) {
return NULL;
}
ldns_write_uint16(rdf_data, size);
memcpy(rdf_data + 2, data, size);
rdf = ldns_rdf_new(LDNS_RDF_TYPE_INT16_DATA, size + 2, rdf_data);
if(!rdf)
LDNS_FREE(rdf_data);
return rdf;
}
/* note: data must be allocated memory */
ldns_rdf *
ldns_rdf_new(ldns_rdf_type type, size_t size, void *data)
{
ldns_rdf *rd;
rd = LDNS_MALLOC(ldns_rdf);
if (!rd) {
return NULL;
}
ldns_rdf_set_size(rd, size);
ldns_rdf_set_type(rd, type);
ldns_rdf_set_data(rd, data);
return rd;
}
ldns_rdf *
ldns_rdf_new_frm_data(ldns_rdf_type type, size_t size, const void *data)
{
ldns_rdf *rdf;
/* if the size is too big, fail */
if (size > LDNS_MAX_RDFLEN) {
return NULL;
}
/* allocate space */
rdf = LDNS_MALLOC(ldns_rdf);
if (!rdf) {
return NULL;
}
rdf->_data = LDNS_XMALLOC(uint8_t, size);
if (!rdf->_data) {
LDNS_FREE(rdf);
return NULL;
}
/* set the values */
ldns_rdf_set_type(rdf, type);
ldns_rdf_set_size(rdf, size);
memcpy(rdf->_data, data, size);
return rdf;
}
ldns_rdf *
ldns_rdf_clone(const ldns_rdf *rd)
{
assert(rd != NULL);
return (ldns_rdf_new_frm_data( ldns_rdf_get_type(rd),
ldns_rdf_size(rd), ldns_rdf_data(rd)));
}
void
ldns_rdf_deep_free(ldns_rdf *rd)
{
if (rd) {
if (rd->_data) {
LDNS_FREE(rd->_data);
}
LDNS_FREE(rd);
}
}
void
ldns_rdf_free(ldns_rdf *rd)
{
if (rd) {
LDNS_FREE(rd);
}
}
ldns_rdf *
ldns_rdf_new_frm_str(ldns_rdf_type type, const char *str)
{
ldns_rdf *rdf = NULL;
ldns_status status;
switch (type) {
case LDNS_RDF_TYPE_DNAME:
status = ldns_str2rdf_dname(&rdf, str);
break;
case LDNS_RDF_TYPE_INT8:
status = ldns_str2rdf_int8(&rdf, str);
break;
case LDNS_RDF_TYPE_INT16:
status = ldns_str2rdf_int16(&rdf, str);
break;
case LDNS_RDF_TYPE_INT32:
status = ldns_str2rdf_int32(&rdf, str);
break;
case LDNS_RDF_TYPE_A:
status = ldns_str2rdf_a(&rdf, str);
break;
case LDNS_RDF_TYPE_AAAA:
status = ldns_str2rdf_aaaa(&rdf, str);
break;
case LDNS_RDF_TYPE_STR:
status = ldns_str2rdf_str(&rdf, str);
break;
case LDNS_RDF_TYPE_APL:
status = ldns_str2rdf_apl(&rdf, str);
break;
case LDNS_RDF_TYPE_B64:
status = ldns_str2rdf_b64(&rdf, str);
break;
case LDNS_RDF_TYPE_B32_EXT:
status = ldns_str2rdf_b32_ext(&rdf, str);
break;
case LDNS_RDF_TYPE_HEX:
status = ldns_str2rdf_hex(&rdf, str);
break;
case LDNS_RDF_TYPE_NSEC:
status = ldns_str2rdf_nsec(&rdf, str);
break;
case LDNS_RDF_TYPE_TYPE:
status = ldns_str2rdf_type(&rdf, str);
break;
case LDNS_RDF_TYPE_CLASS:
status = ldns_str2rdf_class(&rdf, str);
break;
case LDNS_RDF_TYPE_CERT_ALG:
status = ldns_str2rdf_cert_alg(&rdf, str);
break;
case LDNS_RDF_TYPE_ALG:
status = ldns_str2rdf_alg(&rdf, str);
break;
case LDNS_RDF_TYPE_UNKNOWN:
status = ldns_str2rdf_unknown(&rdf, str);
break;
case LDNS_RDF_TYPE_TIME:
status = ldns_str2rdf_time(&rdf, str);
break;
case LDNS_RDF_TYPE_PERIOD:
status = ldns_str2rdf_period(&rdf, str);
break;
case LDNS_RDF_TYPE_HIP:
status = ldns_str2rdf_hip(&rdf, str);
break;
case LDNS_RDF_TYPE_SERVICE:
status = ldns_str2rdf_service(&rdf, str);
break;
case LDNS_RDF_TYPE_LOC:
status = ldns_str2rdf_loc(&rdf, str);
break;
case LDNS_RDF_TYPE_WKS:
status = ldns_str2rdf_wks(&rdf, str);
break;
case LDNS_RDF_TYPE_NSAP:
status = ldns_str2rdf_nsap(&rdf, str);
break;
case LDNS_RDF_TYPE_ATMA:
status = ldns_str2rdf_atma(&rdf, str);
break;
case LDNS_RDF_TYPE_IPSECKEY:
status = ldns_str2rdf_ipseckey(&rdf, str);
break;
case LDNS_RDF_TYPE_NSEC3_SALT:
status = ldns_str2rdf_nsec3_salt(&rdf, str);
break;
case LDNS_RDF_TYPE_NSEC3_NEXT_OWNER:
status = ldns_str2rdf_b32_ext(&rdf, str);
break;
case LDNS_RDF_TYPE_ILNP64:
status = ldns_str2rdf_ilnp64(&rdf, str);
break;
case LDNS_RDF_TYPE_EUI48:
status = ldns_str2rdf_eui48(&rdf, str);
break;
case LDNS_RDF_TYPE_EUI64:
status = ldns_str2rdf_eui64(&rdf, str);
break;
case LDNS_RDF_TYPE_TAG:
status = ldns_str2rdf_tag(&rdf, str);
break;
case LDNS_RDF_TYPE_LONG_STR:
status = ldns_str2rdf_long_str(&rdf, str);
break;
case LDNS_RDF_TYPE_CERTIFICATE_USAGE:
status = ldns_str2rdf_certificate_usage(&rdf, str);
break;
case LDNS_RDF_TYPE_SELECTOR:
status = ldns_str2rdf_selector(&rdf, str);
break;
case LDNS_RDF_TYPE_MATCHING_TYPE:
status = ldns_str2rdf_matching_type(&rdf, str);
break;
case LDNS_RDF_TYPE_AMTRELAY:
status = ldns_str2rdf_amtrelay(&rdf, str);
break;
case LDNS_RDF_TYPE_SVCPARAMS:
status = ldns_str2rdf_svcparams(&rdf, str);
break;
case LDNS_RDF_TYPE_NONE:
default:
/* default default ??? */
status = LDNS_STATUS_ERR;
break;
}
if (LDNS_STATUS_OK == status) {
ldns_rdf_set_type(rdf, type);
return rdf;
}
if (rdf) {
LDNS_FREE(rdf);
}
return NULL;
}
ldns_status
ldns_rdf_new_frm_fp(ldns_rdf **rdf, ldns_rdf_type type, FILE *fp)
{
return ldns_rdf_new_frm_fp_l(rdf, type, fp, NULL);
}
ldns_status
ldns_rdf_new_frm_fp_l(ldns_rdf **rdf, ldns_rdf_type type, FILE *fp, int *line_nr)
{
char *line;
ldns_rdf *r;
ssize_t t;
line = LDNS_XMALLOC(char, LDNS_MAX_LINELEN + 1);
if (!line) {
return LDNS_STATUS_MEM_ERR;
}
/* read an entire line in from the file */
if ((t = ldns_fget_token_l(fp, line, LDNS_PARSE_SKIP_SPACE, 0, line_nr)) == -1 || t == 0) {
LDNS_FREE(line);
return LDNS_STATUS_SYNTAX_RDATA_ERR;
}
r = ldns_rdf_new_frm_str(type, (const char*) line);
LDNS_FREE(line);
if (rdf) {
*rdf = r;
return LDNS_STATUS_OK;
} else {
return LDNS_STATUS_NULL;
}
}
ldns_rdf *
ldns_rdf_address_reverse(const ldns_rdf *rd)
{
uint8_t buf_4[LDNS_IP4ADDRLEN];
uint8_t buf_6[LDNS_IP6ADDRLEN * 2];
ldns_rdf *rev;
ldns_rdf *in_addr;
ldns_rdf *ret_dname;
uint8_t octet;
uint8_t nnibble;
uint8_t nibble;
uint8_t i, j;
char *char_dname;
int nbit;
if (ldns_rdf_get_type(rd) != LDNS_RDF_TYPE_A &&
ldns_rdf_get_type(rd) != LDNS_RDF_TYPE_AAAA) {
return NULL;
}
in_addr = NULL;
ret_dname = NULL;
switch(ldns_rdf_get_type(rd)) {
case LDNS_RDF_TYPE_A:
/* the length of the buffer is 4 */
buf_4[3] = ldns_rdf_data(rd)[0];
buf_4[2] = ldns_rdf_data(rd)[1];
buf_4[1] = ldns_rdf_data(rd)[2];
buf_4[0] = ldns_rdf_data(rd)[3];
in_addr = ldns_dname_new_frm_str("in-addr.arpa.");
if (!in_addr) {
return NULL;
}
/* make a new rdf and convert that back */
rev = ldns_rdf_new_frm_data( LDNS_RDF_TYPE_A,
LDNS_IP4ADDRLEN, (void*)&buf_4);
if (!rev) {
LDNS_FREE(in_addr);
return NULL;
}
/* convert rev to a string */
char_dname = ldns_rdf2str(rev);
if (!char_dname) {
LDNS_FREE(in_addr);
ldns_rdf_deep_free(rev);
return NULL;
}
/* transform back to rdf with type dname */
ret_dname = ldns_dname_new_frm_str(char_dname);
if (!ret_dname) {
LDNS_FREE(in_addr);
ldns_rdf_deep_free(rev);
LDNS_FREE(char_dname);
return NULL;
}
/* not needed anymore */
ldns_rdf_deep_free(rev);
LDNS_FREE(char_dname);
break;
case LDNS_RDF_TYPE_AAAA:
/* some foo magic to reverse the nibbles ... */
for (nbit = 127; nbit >= 0; nbit = nbit - 4) {
/* calculate octet (8 bit) */
octet = ( ((unsigned int) nbit) & 0x78) >> 3;
/* calculate nibble */
nnibble = ( ((unsigned int) nbit) & 0x04) >> 2;
/* extract nibble */
nibble = (ldns_rdf_data(rd)[octet] & ( 0xf << (4 * (1 -
nnibble)) ) ) >> ( 4 * (1 -
nnibble));
buf_6[(LDNS_IP6ADDRLEN * 2 - 1) -
(octet * 2 + nnibble)] =
(uint8_t)ldns_int_to_hexdigit((int)nibble);
}
char_dname = LDNS_XMALLOC(char, (LDNS_IP6ADDRLEN * 4));
if (!char_dname) {
return NULL;
}
char_dname[LDNS_IP6ADDRLEN * 4 - 1] = '\0'; /* closure */
/* walk the string and add . 's */
for (i = 0, j = 0; i < LDNS_IP6ADDRLEN * 2; i++, j = j + 2) {
char_dname[j] = (char)buf_6[i];
if (i != LDNS_IP6ADDRLEN * 2 - 1) {
char_dname[j + 1] = '.';
}
}
in_addr = ldns_dname_new_frm_str("ip6.arpa.");
if (!in_addr) {
LDNS_FREE(char_dname);
return NULL;
}
/* convert rev to a string */
ret_dname = ldns_dname_new_frm_str(char_dname);
LDNS_FREE(char_dname);
if (!ret_dname) {
ldns_rdf_deep_free(in_addr);
return NULL;
}
break;
default:
break;
}
/* add the suffix */
rev = ldns_dname_cat_clone(ret_dname, in_addr);
ldns_rdf_deep_free(ret_dname);
ldns_rdf_deep_free(in_addr);
return rev;
}
ldns_status
ldns_rdf_hip_get_alg_hit_pk(ldns_rdf *rdf, uint8_t* alg,
uint8_t *hit_size, uint8_t** hit,
uint16_t *pk_size, uint8_t** pk)
{
uint8_t *data;
size_t rdf_size;
if (! rdf || ! alg || ! hit || ! hit_size || ! pk || ! pk_size) {
return LDNS_STATUS_INVALID_POINTER;
} else if (ldns_rdf_get_type(rdf) != LDNS_RDF_TYPE_HIP) {
return LDNS_STATUS_INVALID_RDF_TYPE;
} else if ((rdf_size = ldns_rdf_size(rdf)) < 6) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
data = ldns_rdf_data(rdf);
*hit_size = data[0];
*alg = data[1];
*pk_size = ldns_read_uint16(data + 2);
*hit = data + 4;
*pk = data + 4 + *hit_size;
if (*hit_size == 0 || *pk_size == 0 ||
rdf_size < (size_t) *hit_size + *pk_size + 4) {
return LDNS_STATUS_WIRE_RDATA_ERR;
}
return LDNS_STATUS_OK;
}
ldns_status
ldns_rdf_hip_new_frm_alg_hit_pk(ldns_rdf** rdf, uint8_t alg,
uint8_t hit_size, uint8_t *hit,
uint16_t pk_size, uint8_t *pk)
{
uint8_t *data;
if (! rdf) {
return LDNS_STATUS_INVALID_POINTER;
}
if (4 + hit_size + pk_size > LDNS_MAX_RDFLEN) {
return LDNS_STATUS_RDATA_OVERFLOW;
}
data = LDNS_XMALLOC(uint8_t, 4 + hit_size + pk_size);
if (data == NULL) {
return LDNS_STATUS_MEM_ERR;
}
data[0] = hit_size;
data[1] = alg;
ldns_write_uint16(data + 2, pk_size);
memcpy(data + 4, hit, hit_size);
memcpy(data + 4 + hit_size, pk, pk_size);
*rdf = ldns_rdf_new(LDNS_RDF_TYPE_HIP, 4 + hit_size + pk_size, data);
if (! *rdf) {
LDNS_FREE(data);
return LDNS_STATUS_MEM_ERR;
}
return LDNS_STATUS_OK;
}
ldns_status
ldns_octet(char *word, size_t *length)
{
char *s;
char *p;
*length = 0;
for (s = p = word; *s != '\0'; s++,p++) {
switch (*s) {
case '.':
if (s[1] == '.') {
return LDNS_STATUS_EMPTY_LABEL;
}
*p = *s;
(*length)++;
break;
case '\\':
if ('0' <= s[1] && s[1] <= '9' &&
'0' <= s[2] && s[2] <= '9' &&
'0' <= s[3] && s[3] <= '9') {
/* \DDD seen */
int val = ((s[1] - '0') * 100 +
(s[2] - '0') * 10 + (s[3] - '0'));
if (0 <= val && val <= 255) {
/* this also handles \0 */
s += 3;
*p = val;
(*length)++;
} else {
return LDNS_STATUS_DDD_OVERFLOW;
}
} else {
/* an escaped character, like <space> ?
* remove the '\' keep the rest */
*p = *++s;
(*length)++;
}
break;
case '\"':
/* non quoted " Is either first or the last character in
* the string */
*p = *++s; /* skip it */
(*length)++;
/* I'm not sure if this is needed in libdns... MG */
if ( *s == '\0' ) {
/* ok, it was the last one */
*p = '\0';
return LDNS_STATUS_OK;
}
break;
default:
*p = *s;
(*length)++;
break;
}
}
*p = '\0';
return LDNS_STATUS_OK;
}
int
ldns_rdf_compare(const ldns_rdf *rd1, const ldns_rdf *rd2)
{
uint16_t i1, i2, i;
uint8_t *d1, *d2;
/* only when both are not NULL we can say anything about them */
if (!rd1 && !rd2) {
return 0;
}
if (!rd1 || !rd2) {
return -1;
}
i1 = ldns_rdf_size(rd1);
i2 = ldns_rdf_size(rd2);
if (i1 < i2) {
return -1;
} else if (i1 > i2) {
return +1;
} else {
d1 = (uint8_t*)ldns_rdf_data(rd1);
d2 = (uint8_t*)ldns_rdf_data(rd2);
for(i = 0; i < i1; i++) {
if (d1[i] < d2[i]) {
return -1;
} else if (d1[i] > d2[i]) {
return +1;
}
}
}
return 0;
}
uint32_t
ldns_str2period(const char *nptr, const char **endptr)
{
int sign = 0;
uint32_t i = 0;
uint32_t seconds = 0;
for(*endptr = nptr; **endptr; (*endptr)++) {
switch (**endptr) {
case ' ':
case '\t':
break;
case '-':
if(sign == 0) {
sign = -1;
} else {
return seconds;
}
break;
case '+':
if(sign == 0) {
sign = 1;
} else {
return seconds;
}
break;
case 's':
case 'S':
seconds += i;
i = 0;
break;
case 'm':
case 'M':
seconds += i * 60;
i = 0;
break;
case 'h':
case 'H':
seconds += i * 60 * 60;
i = 0;
break;
case 'd':
case 'D':
seconds += i * 60 * 60 * 24;
i = 0;
break;
case 'w':
case 'W':
seconds += i * 60 * 60 * 24 * 7;
i = 0;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
i *= 10;
i += (**endptr - '0');
break;
default:
seconds += i;
/* disregard signedness */
return seconds;
}
}
seconds += i;
/* disregard signedness */
return seconds;
}
config.h
ldns_dname_cat_clone
ldns_rdf * ldns_dname_cat_clone(const ldns_rdf *rd1, const ldns_rdf *rd2)
concatenates two dnames together
Definition dname.c:52
ldns_dname_new_frm_str
ldns_rdf * ldns_dname_new_frm_str(const char *str)
creates a new dname rdf from a string.
Definition dname.c:268
LDNS_STATUS_WIRE_RDATA_ERR
@ LDNS_STATUS_WIRE_RDATA_ERR
Definition error.h:125
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_SYNTAX_RDATA_ERR
@ LDNS_STATUS_SYNTAX_RDATA_ERR
Definition error.h:83
LDNS_STATUS_INVALID_POINTER
@ LDNS_STATUS_INVALID_POINTER
Definition error.h:33
LDNS_STATUS_DDD_OVERFLOW
@ LDNS_STATUS_DDD_OVERFLOW
Definition error.h:31
LDNS_STATUS_INVALID_RDF_TYPE
@ LDNS_STATUS_INVALID_RDF_TYPE
Definition error.h:128
LDNS_STATUS_OK
@ LDNS_STATUS_OK
Definition error.h:26
LDNS_STATUS_EMPTY_LABEL
@ LDNS_STATUS_EMPTY_LABEL
Definition error.h:27
LDNS_STATUS_RDATA_OVERFLOW
@ LDNS_STATUS_RDATA_OVERFLOW
Definition error.h:129
ldns_status
enum ldns_enum_status ldns_status
Definition error.h:148
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.h
Including this file will include all ldns files, and define some lookup tables.
LDNS_IP4ADDRLEN
#define LDNS_IP4ADDRLEN
Definition ldns.h:132
LDNS_IP6ADDRLEN
#define LDNS_IP6ADDRLEN
Definition ldns.h:133
ldns_fget_token_l
ssize_t ldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *line_nr)
returns a token/char from the stream F.
Definition parse.c:247
LDNS_PARSE_SKIP_SPACE
#define LDNS_PARSE_SKIP_SPACE
Definition parse.h:20
LDNS_MAX_LINELEN
#define LDNS_MAX_LINELEN
Definition parse.h:23
ldns_str2period
uint32_t ldns_str2period(const char *nptr, const char **endptr)
converts a ttl value (like 5d2h) to a long.
Definition rdata.c:691
ldns_rdf_hip_new_frm_alg_hit_pk
ldns_status ldns_rdf_hip_new_frm_alg_hit_pk(ldns_rdf **rdf, uint8_t alg, uint8_t hit_size, uint8_t *hit, uint16_t pk_size, uint8_t *pk)
Creates a new LDNS_RDF_TYPE_HIP rdf from given data.
Definition rdata.c:565
ldns_rdf_new_frm_str
ldns_rdf * ldns_rdf_new_frm_str(ldns_rdf_type type, const char *str)
creates a new rdf from a string.
Definition rdata.c:249
ldns_rdf_data
uint8_t * ldns_rdf_data(const ldns_rdf *rd)
returns the data of the rdf.
Definition rdata.c:38
ldns_rdf_clone
ldns_rdf * ldns_rdf_clone(const ldns_rdf *rd)
clones a rdf structure.
Definition rdata.c:222
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_set_type
void ldns_rdf_set_type(ldns_rdf *rd, ldns_rdf_type type)
sets the size of the rdf.
Definition rdata.c:53
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_native2rdf_int16
ldns_rdf * ldns_native2rdf_int16(ldns_rdf_type type, uint16_t value)
returns the rdf containing the native uint16_t representation.
Definition rdata.c:132
ldns_octet
ldns_status ldns_octet(char *word, size_t *length)
removes \DDD, \[space] and other escapes from the input.
Definition rdata.c:595
ldns_native2rdf_int16_data
ldns_rdf * ldns_native2rdf_int16_data(size_t size, uint8_t *data)
returns an int16_data rdf that contains the data in the given array, preceded by an int16 specifying ...
Definition rdata.c:162
ldns_rdf_new_frm_fp
ldns_status ldns_rdf_new_frm_fp(ldns_rdf **rdf, ldns_rdf_type type, FILE *fp)
creates a new rdf from a file containing a string.
Definition rdata.c:386
ldns_native2rdf_int8
ldns_rdf * ldns_native2rdf_int8(ldns_rdf_type type, uint8_t value)
returns the rdf containing the native uint8_t repr.
Definition rdata.c:126
ldns_rdf2native_int8
uint8_t ldns_rdf2native_int8(const ldns_rdf *rd)
returns the native uint8_t representation from the rdf.
Definition rdata.c:70
ldns_native2rdf_int32
ldns_rdf * ldns_native2rdf_int32(ldns_rdf_type type, uint32_t value)
returns an rdf that contains the given int32 value.
Definition rdata.c:147
ldns_rdf_hip_get_alg_hit_pk
ldns_status ldns_rdf_hip_get_alg_hit_pk(ldns_rdf *rdf, uint8_t *alg, uint8_t *hit_size, uint8_t **hit, uint16_t *pk_size, uint8_t **pk)
Gets the algorithm value, the HIT and Public Key data from the rdf with type LDNS_RDF_TYPE_HIP.
Definition rdata.c:537
ldns_rdf_size
size_t ldns_rdf_size(const ldns_rdf *rd)
returns the size of the rdf.
Definition rdata.c:24
ldns_rdf2native_time_t
time_t ldns_rdf2native_time_t(const ldns_rdf *rd)
returns the native time_t representation from the rdf.
Definition rdata.c:112
ldns_rdf_set_data
void ldns_rdf_set_data(ldns_rdf *rd, void *data)
sets the size of the rdf.
Definition rdata.c:60
ldns_rdf_set_size
void ldns_rdf_set_size(ldns_rdf *rd, size_t size)
sets the size of the rdf.
Definition rdata.c:46
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_rdf_free
void ldns_rdf_free(ldns_rdf *rd)
frees a rdf structure, leaving the data pointer intact.
Definition rdata.c:241
ldns_rdf_compare
int ldns_rdf_compare(const ldns_rdf *rd1, const ldns_rdf *rd2)
compares two rdf's on their wire formats.
Definition rdata.c:657
ldns_rdf_address_reverse
ldns_rdf * ldns_rdf_address_reverse(const ldns_rdf *rd)
reverses an rdf, only actually useful for AAAA and A records.
Definition rdata.c:419
ldns_rdf_new_frm_fp_l
ldns_status ldns_rdf_new_frm_fp_l(ldns_rdf **rdf, ldns_rdf_type type, FILE *fp, int *line_nr)
creates a new rdf from a file containing a string.
Definition rdata.c:392
LDNS_RDF_SIZE_WORD
#define LDNS_RDF_SIZE_WORD
Definition rdata.h:34
LDNS_MAX_RDFLEN
#define LDNS_MAX_RDFLEN
Definition rdata.h:31
LDNS_RDF_SIZE_BYTE
#define LDNS_RDF_SIZE_BYTE
Definition rdata.h:33
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_TYPE
@ LDNS_RDF_TYPE_TYPE
a RR type
Definition rdata.h:74
LDNS_RDF_SIZE_DOUBLEWORD
#define LDNS_RDF_SIZE_DOUBLEWORD
Definition rdata.h:35
ldns_rdf_type
enum ldns_enum_rdf_type ldns_rdf_type
Definition rdata.h:151
ldns_str2rdf_hex
ldns_status ldns_str2rdf_hex(ldns_rdf **rd, const char *str)
convert a hex value into wireformat
Definition str2host.c:644
ldns_str2rdf_amtrelay
ldns_status ldns_str2rdf_amtrelay(ldns_rdf **rd, const char *str)
Convert a "<precedence> <D-bit> <type> <relay>" encoding of the value field as specified in Section 4...
Definition str2host.c:1672
ldns_str2rdf_int8
ldns_status ldns_str2rdf_int8(ldns_rdf **rd, const char *bytestr)
convert a byte into wireformat
Definition str2host.c:228
ldns_str2rdf_certificate_usage
ldns_status ldns_str2rdf_certificate_usage(ldns_rdf **rd, const char *str)
convert a tlsa certificate usage value into wireformat
Definition str2host.c:839
ldns_str2rdf_hip
ldns_status ldns_str2rdf_hip(ldns_rdf **rd, const char *str)
Convert a "<algorithm> <hit> <pk>" encoding of the value field as specified in Section 6.
Definition str2host.c:1576
ldns_str2rdf_service
ldns_status ldns_str2rdf_service(ldns_rdf **rd, const char *str)
convert string with a protocol service into wireformat
ldns_str2rdf_atma
ldns_status ldns_str2rdf_atma(ldns_rdf **rd, const char *str)
convert a str with a ATMA RR into wireformat
Definition str2host.c:1255
ldns_str2rdf_type
ldns_status ldns_str2rdf_type(ldns_rdf **rd, const char *str)
convert a rrtype into wireformat
Definition str2host.c:738
ldns_str2rdf_nsec3_salt
ldns_status ldns_str2rdf_nsec3_salt(ldns_rdf **rd, const char *nsec3_salt)
Definition str2host.c:126
ldns_str2rdf_svcparams
ldns_status ldns_str2rdf_svcparams(ldns_rdf **rd, const char *str)
Convert a series of "key[=<value>]" encodings to wireformat as described in [draft-ietf-dnsop-svcb-ht...
Definition str2host.c:2331
ldns_str2rdf_period
ldns_status ldns_str2rdf_period(ldns_rdf **rd, const char *str)
Definition str2host.c:178
ldns_str2rdf_aaaa
ldns_status ldns_str2rdf_aaaa(ldns_rdf **rd, const char *str)
convert the str with an AAAA record into wireformat
Definition str2host.c:414
ldns_str2rdf_b32_ext
ldns_status ldns_str2rdf_b32_ext(ldns_rdf **rd, const char *str)
convert the string with the b32 ext hex data into wireformat
Definition str2host.c:613
ldns_str2rdf_long_str
ldns_status ldns_str2rdf_long_str(ldns_rdf **rd, const char *str)
Convert a <character-string> encoding of the value field as specified [RFC1035], Section 5....
Definition str2host.c:1529
ldns_str2rdf_class
ldns_status ldns_str2rdf_class(ldns_rdf **rd, const char *str)
convert string with a classname into wireformat
Definition str2host.c:749
ldns_str2rdf_alg
ldns_status ldns_str2rdf_alg(ldns_rdf **rd, const char *str)
convert an algorithm value into wireformat
Definition str2host.c:833
ldns_str2rdf_nsec
ldns_status ldns_str2rdf_nsec(ldns_rdf **rd, const char *str)
convert string with nsec into wireformat
Definition str2host.c:690
ldns_str2rdf_a
ldns_status ldns_str2rdf_a(ldns_rdf **rd, const char *str)
convert str with an A record into wireformat
Definition str2host.c:401
ldns_str2rdf_matching_type
ldns_status ldns_str2rdf_matching_type(ldns_rdf **rd, const char *str)
convert a tlsa matching type value into wireformat
Definition str2host.c:852
ldns_str2rdf_wks
ldns_status ldns_str2rdf_wks(ldns_rdf **rd, const char *str)
convert string with a WKS RR into wireformat
Definition str2host.c:1091
ldns_str2rdf_ilnp64
ldns_status ldns_str2rdf_ilnp64(ldns_rdf **rd, const char *str)
convert 4 * 16bit hex separated by colons into wireformat
Definition str2host.c:1429
ldns_str2rdf_time
ldns_status ldns_str2rdf_time(ldns_rdf **rd, const char *time)
convert a time string to a time value in wireformat
Definition str2host.c:57
ldns_str2rdf_nsap
ldns_status ldns_str2rdf_nsap(ldns_rdf **rd, const char *str)
convert a str with a NSAP RR into wireformat
Definition str2host.c:1236
ldns_str2rdf_eui64
ldns_status ldns_str2rdf_eui64(ldns_rdf **rd, const char *str)
convert 8 hex bytes separated by dashes into wireformat
Definition str2host.c:1475
ldns_str2rdf_loc
ldns_status ldns_str2rdf_loc(ldns_rdf **rd, const char *str)
convert a string with a LOC RR into wireformat
Definition str2host.c:916
ldns_str2rdf_str
ldns_status ldns_str2rdf_str(ldns_rdf **rd, const char *str)
convert a string into wireformat (think txt record)
Definition str2host.c:428
ldns_str2rdf_ipseckey
ldns_status ldns_str2rdf_ipseckey(ldns_rdf **rd, const char *str)
convert a str with a IPSECKEY RR into wireformat
Definition str2host.c:1275
ldns_str2rdf_selector
ldns_status ldns_str2rdf_selector(ldns_rdf **rd, const char *str)
convert a tlsa selector value into wireformat
Definition str2host.c:846
ldns_str2rdf_tag
ldns_status ldns_str2rdf_tag(ldns_rdf **rd, const char *str)
Convert a non-zero sequence of US-ASCII letters and numbers into wireformat.
Definition str2host.c:1500
ldns_str2rdf_apl
ldns_status ldns_str2rdf_apl(ldns_rdf **rd, const char *str)
convert str with the apl record into wireformat
Definition str2host.c:472
ldns_str2rdf_b64
ldns_status ldns_str2rdf_b64(ldns_rdf **rd, const char *str)
convert the string with the b64 data into wireformat
Definition str2host.c:583
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_str2rdf_eui48
ldns_status ldns_str2rdf_eui48(ldns_rdf **rd, const char *str)
convert 6 hex bytes separated by dashes into wireformat
Definition str2host.c:1452
ldns_str2rdf_int32
ldns_status ldns_str2rdf_int32(ldns_rdf **rd, const char *longstr)
convert a strings into a 4 byte int in wireformat
Definition str2host.c:197
ldns_str2rdf_int16
ldns_status ldns_str2rdf_int16(ldns_rdf **rd, const char *shortstr)
convert a string to a int16 in wireformat
Definition str2host.c:36
ldns_str2rdf_cert_alg
ldns_status ldns_str2rdf_cert_alg(ldns_rdf **rd, const char *str)
convert an certificate algorithm value into wireformat
Definition str2host.c:763
ldns_str2rdf_unknown
ldns_status ldns_str2rdf_unknown(ldns_rdf **rd, const char *str)
convert a string with a unknown RR into wireformat
ldns_struct_rdf
Resource record data field.
Definition rdata.h:197
ldns_struct_rdf::_type
ldns_rdf_type _type
The type of the data.
Definition rdata.h:201
ldns_struct_rdf::_size
size_t _size
The size of the data (in octets)
Definition rdata.h:199
ldns_struct_rdf::_data
void * _data
Pointer to the data (raw octets)
Definition rdata.h:203
LDNS_FREE
#define LDNS_FREE(ptr)
Definition util.h:60
LDNS_MALLOC
#define LDNS_MALLOC(type)
Memory management macros.
Definition util.h:49
LDNS_XMALLOC
#define LDNS_XMALLOC(type, count)
Definition util.h:51
ldns_int_to_hexdigit
char ldns_int_to_hexdigit(int ch)
Returns the char (hex) representation of the given int.
Definition util.c:113