rdata.h File Reference

Defines ldns_rdf and functions to manipulate those. More...

Go to the source code of this file.

Data Structures

struct  ldns_struct_rdf
 Resource record data field. More...
 

Macros

#define LDNS_MAX_RDFLEN   65535
 
#define LDNS_RDF_SIZE_BYTE   1
 
#define LDNS_RDF_SIZE_WORD   2
 
#define LDNS_RDF_SIZE_DOUBLEWORD   4
 
#define LDNS_RDF_SIZE_6BYTES   6
 
#define LDNS_RDF_SIZE_8BYTES   8
 
#define LDNS_RDF_SIZE_16BYTES   16
 
#define LDNS_NSEC3_VARS_OPTOUT_MASK   0x01
 

Typedefs

typedef enum ldns_enum_rdf_type ldns_rdf_type
 
typedef enum ldns_enum_cert_algorithm ldns_cert_algorithm
 
typedef enum ldns_enum_svcparam_key ldns_svcparam_key
 
typedef struct ldns_struct_rdf ldns_rdf
 

Enumerations

enum  ldns_enum_rdf_type {
  LDNS_RDF_TYPE_NONE , LDNS_RDF_TYPE_DNAME , LDNS_RDF_TYPE_INT8 , LDNS_RDF_TYPE_INT16 ,
  LDNS_RDF_TYPE_INT32 , LDNS_RDF_TYPE_A , LDNS_RDF_TYPE_AAAA , LDNS_RDF_TYPE_STR ,
  LDNS_RDF_TYPE_APL , LDNS_RDF_TYPE_B32_EXT , LDNS_RDF_TYPE_B64 , LDNS_RDF_TYPE_HEX ,
  LDNS_RDF_TYPE_NSEC , LDNS_RDF_TYPE_TYPE , LDNS_RDF_TYPE_CLASS , LDNS_RDF_TYPE_CERT_ALG ,
  LDNS_RDF_TYPE_ALG , LDNS_RDF_TYPE_UNKNOWN , LDNS_RDF_TYPE_TIME , LDNS_RDF_TYPE_PERIOD ,
  LDNS_RDF_TYPE_TSIGTIME , LDNS_RDF_TYPE_HIP , LDNS_RDF_TYPE_INT16_DATA , LDNS_RDF_TYPE_SERVICE ,
  LDNS_RDF_TYPE_LOC , LDNS_RDF_TYPE_WKS , LDNS_RDF_TYPE_NSAP , LDNS_RDF_TYPE_ATMA ,
  LDNS_RDF_TYPE_IPSECKEY , LDNS_RDF_TYPE_NSEC3_SALT , LDNS_RDF_TYPE_NSEC3_NEXT_OWNER , LDNS_RDF_TYPE_ILNP64 ,
  LDNS_RDF_TYPE_EUI48 , LDNS_RDF_TYPE_EUI64 , LDNS_RDF_TYPE_TAG , LDNS_RDF_TYPE_LONG_STR ,
  LDNS_RDF_TYPE_CERTIFICATE_USAGE , LDNS_RDF_TYPE_SELECTOR , LDNS_RDF_TYPE_MATCHING_TYPE , LDNS_RDF_TYPE_AMTRELAY ,
  LDNS_RDF_TYPE_SVCPARAMS , LDNS_RDF_TYPE_BITMAP = LDNS_RDF_TYPE_NSEC
}
 The different types of RDATA fields. More...
 
enum  ldns_enum_cert_algorithm {
  LDNS_CERT_PKIX = 1 , LDNS_CERT_SPKI = 2 , LDNS_CERT_PGP = 3 , LDNS_CERT_IPKIX = 4 ,
  LDNS_CERT_ISPKI = 5 , LDNS_CERT_IPGP = 6 , LDNS_CERT_ACPKIX = 7 , LDNS_CERT_IACPKIX = 8 ,
  LDNS_CERT_URI = 253 , LDNS_CERT_OID = 254
}
 algorithms used in CERT rrs More...
 
enum  ldns_enum_svcparam_key {
  LDNS_SVCPARAM_KEY_MANDATORY = 0 , LDNS_SVCPARAM_KEY_ALPN = 1 , LDNS_SVCPARAM_KEY_NO_DEFAULT_ALPN = 2 , LDNS_SVCPARAM_KEY_PORT = 3 ,
  LDNS_SVCPARAM_KEY_IPV4HINT = 4 , LDNS_SVCPARAM_KEY_ECH = 5 , LDNS_SVCPARAM_KEY_IPV6HINT = 6 , LDNS_SVCPARAM_KEY_DOHPATH = 7 ,
  LDNS_SVCPARAM_KEY_LAST_KEY = 7 , LDNS_SVCPARAM_KEY_RESERVED = 65535
}
 keys types in SVCPARAMS rdata fields More...
 

Functions

void ldns_rdf_set_size (ldns_rdf *rd, size_t size)
 sets the size of the rdf. More...
 
void ldns_rdf_set_type (ldns_rdf *rd, ldns_rdf_type type)
 sets the size of the rdf. More...
 
void ldns_rdf_set_data (ldns_rdf *rd, void *data)
 sets the size of the rdf. More...
 
size_t ldns_rdf_size (const ldns_rdf *rd)
 returns the size of the rdf. More...
 
ldns_rdf_type ldns_rdf_get_type (const ldns_rdf *rd)
 returns the type of the rdf. More...
 
uint8_t * ldns_rdf_data (const ldns_rdf *rd)
 returns the data of the rdf. More...
 
ldns_rdfldns_rdf_new (ldns_rdf_type type, size_t size, void *data)
 allocates a new rdf structure and fills it. More...
 
ldns_rdfldns_rdf_new_frm_data (ldns_rdf_type type, size_t size, const void *data)
 allocates a new rdf structure and fills it. More...
 
ldns_rdfldns_rdf_new_frm_str (ldns_rdf_type type, const char *str)
 creates a new rdf from a string. More...
 
ldns_status ldns_rdf_new_frm_fp (ldns_rdf **r, ldns_rdf_type type, FILE *fp)
 creates a new rdf from a file containing a string. More...
 
ldns_status ldns_rdf_new_frm_fp_l (ldns_rdf **r, ldns_rdf_type type, FILE *fp, int *line_nr)
 creates a new rdf from a file containing a string. More...
 
void ldns_rdf_free (ldns_rdf *rd)
 frees a rdf structure, leaving the data pointer intact. More...
 
void ldns_rdf_deep_free (ldns_rdf *rd)
 frees a rdf structure and frees the data. More...
 
ldns_rdfldns_native2rdf_int8 (ldns_rdf_type type, uint8_t value)
 returns the rdf containing the native uint8_t repr. More...
 
ldns_rdfldns_native2rdf_int16 (ldns_rdf_type type, uint16_t value)
 returns the rdf containing the native uint16_t representation. More...
 
ldns_rdfldns_native2rdf_int32 (ldns_rdf_type type, uint32_t value)
 returns an rdf that contains the given int32 value. More...
 
ldns_rdfldns_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 the length. More...
 
ldns_rdfldns_rdf_address_reverse (const ldns_rdf *rd)
 reverses an rdf, only actually useful for AAAA and A records. More...
 
uint8_t ldns_rdf2native_int8 (const ldns_rdf *rd)
 returns the native uint8_t representation from the rdf. More...
 
uint16_t ldns_rdf2native_int16 (const ldns_rdf *rd)
 returns the native uint16_t representation from the rdf. More...
 
uint32_t ldns_rdf2native_int32 (const ldns_rdf *rd)
 returns the native uint32_t representation from the rdf. More...
 
time_t ldns_rdf2native_time_t (const ldns_rdf *rd)
 returns the native time_t representation from the rdf. More...
 
uint32_t ldns_str2period (const char *nptr, const char **endptr)
 converts a ttl value (like 5d2h) to a long. More...
 
ldns_status ldns_octet (char *word, size_t *length)
 removes \DDD, \[space] and other escapes from the input. More...
 
ldns_rdfldns_rdf_clone (const ldns_rdf *rd)
 clones a rdf structure. More...
 
int ldns_rdf_compare (const ldns_rdf *rd1, const ldns_rdf *rd2)
 compares two rdf's on their wire formats. More...
 
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. More...
 
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. More...
 

Detailed Description

Defines ldns_rdf and functions to manipulate those.

Definition in file rdata.h.

Macro Definition Documentation

◆ LDNS_MAX_RDFLEN

#define LDNS_MAX_RDFLEN   65535

Definition at line 31 of file rdata.h.

◆ LDNS_RDF_SIZE_BYTE

#define LDNS_RDF_SIZE_BYTE   1

Definition at line 33 of file rdata.h.

◆ LDNS_RDF_SIZE_WORD

#define LDNS_RDF_SIZE_WORD   2

Definition at line 34 of file rdata.h.

◆ LDNS_RDF_SIZE_DOUBLEWORD

#define LDNS_RDF_SIZE_DOUBLEWORD   4

Definition at line 35 of file rdata.h.

◆ LDNS_RDF_SIZE_6BYTES

#define LDNS_RDF_SIZE_6BYTES   6

Definition at line 36 of file rdata.h.

◆ LDNS_RDF_SIZE_8BYTES

#define LDNS_RDF_SIZE_8BYTES   8

Definition at line 37 of file rdata.h.

◆ LDNS_RDF_SIZE_16BYTES

#define LDNS_RDF_SIZE_16BYTES   16

Definition at line 38 of file rdata.h.

◆ LDNS_NSEC3_VARS_OPTOUT_MASK

#define LDNS_NSEC3_VARS_OPTOUT_MASK   0x01

Definition at line 40 of file rdata.h.

Typedef Documentation

◆ ldns_rdf_type

Definition at line 1 of file rdata.h.

◆ ldns_cert_algorithm

Definition at line 1 of file rdata.h.

◆ ldns_svcparam_key

Definition at line 1 of file rdata.h.

◆ ldns_rdf

typedef struct ldns_struct_rdf ldns_rdf

Definition at line 1 of file rdata.h.

Enumeration Type Documentation

◆ ldns_enum_rdf_type

The different types of RDATA fields.

Enumerator
LDNS_RDF_TYPE_NONE 

none

LDNS_RDF_TYPE_DNAME 

domain name

LDNS_RDF_TYPE_INT8 

8 bits

LDNS_RDF_TYPE_INT16 

16 bits

LDNS_RDF_TYPE_INT32 

32 bits

LDNS_RDF_TYPE_A 

A record.

LDNS_RDF_TYPE_AAAA 

AAAA record.

LDNS_RDF_TYPE_STR 

txt string

LDNS_RDF_TYPE_APL 

apl data

LDNS_RDF_TYPE_B32_EXT 

b32 string

LDNS_RDF_TYPE_B64 

b64 string

LDNS_RDF_TYPE_HEX 

hex string

LDNS_RDF_TYPE_NSEC 

nsec type codes

LDNS_RDF_TYPE_TYPE 

a RR type

LDNS_RDF_TYPE_CLASS 

a class

LDNS_RDF_TYPE_CERT_ALG 

certificate algorithm

LDNS_RDF_TYPE_ALG 

a key algorithm

LDNS_RDF_TYPE_UNKNOWN 

unknown types

LDNS_RDF_TYPE_TIME 

time (32 bits)

LDNS_RDF_TYPE_PERIOD 

period

LDNS_RDF_TYPE_TSIGTIME 

tsig time 48 bits

LDNS_RDF_TYPE_HIP 

Represents the Public Key Algorithm, HIT and Public Key fields for the HIP RR types.

A HIP specific rdf type is used because of the unusual layout in wireformat (see RFC 5205 Section 5)

LDNS_RDF_TYPE_INT16_DATA 

variable length any type rdata where the length is specified by the first 2 bytes

LDNS_RDF_TYPE_SERVICE 

protocol and port bitmaps

LDNS_RDF_TYPE_LOC 

location data

LDNS_RDF_TYPE_WKS 

well known services

LDNS_RDF_TYPE_NSAP 

NSAP.

LDNS_RDF_TYPE_ATMA 

ATMA.

LDNS_RDF_TYPE_IPSECKEY 

IPSECKEY.

LDNS_RDF_TYPE_NSEC3_SALT 

nsec3 hash salt

LDNS_RDF_TYPE_NSEC3_NEXT_OWNER 

nsec3 base32 string (with length byte on wire

LDNS_RDF_TYPE_ILNP64 

4 shorts represented as 4 * 16 bit hex numbers separated by colons.

For NID and L64.

LDNS_RDF_TYPE_EUI48 

6 * 8 bit hex numbers separated by dashes.

For EUI48.

LDNS_RDF_TYPE_EUI64 

8 * 8 bit hex numbers separated by dashes.

For EUI64.

LDNS_RDF_TYPE_TAG 

A non-zero sequence of US-ASCII letters and numbers in lower case.

For CAA.

LDNS_RDF_TYPE_LONG_STR 

A <character-string> encoding of the value field as specified [RFC1035], Section 5.1., encoded as remaining rdata.

For CAA.

LDNS_RDF_TYPE_CERTIFICATE_USAGE 

Since RFC7218 TLSA records can be given with mnemonics, hence these rdata field types.

But as with DNSKEYs, the output is always numeric.

LDNS_RDF_TYPE_SELECTOR 
LDNS_RDF_TYPE_MATCHING_TYPE 
LDNS_RDF_TYPE_AMTRELAY 

draft-ietf-mboned-driad-amt-discovery

LDNS_RDF_TYPE_SVCPARAMS 

draft-ietf-dnsop-svcb-https

LDNS_RDF_TYPE_BITMAP 

Definition at line 45 of file rdata.h.

◆ ldns_enum_cert_algorithm

algorithms used in CERT rrs

Enumerator
LDNS_CERT_PKIX 
LDNS_CERT_SPKI 
LDNS_CERT_PGP 
LDNS_CERT_IPKIX 
LDNS_CERT_ISPKI 
LDNS_CERT_IPGP 
LDNS_CERT_ACPKIX 
LDNS_CERT_IACPKIX 
LDNS_CERT_URI 
LDNS_CERT_OID 

Definition at line 156 of file rdata.h.

◆ ldns_enum_svcparam_key

keys types in SVCPARAMS rdata fields

Enumerator
LDNS_SVCPARAM_KEY_MANDATORY 
LDNS_SVCPARAM_KEY_ALPN 
LDNS_SVCPARAM_KEY_NO_DEFAULT_ALPN 
LDNS_SVCPARAM_KEY_PORT 
LDNS_SVCPARAM_KEY_IPV4HINT 
LDNS_SVCPARAM_KEY_ECH 
LDNS_SVCPARAM_KEY_IPV6HINT 
LDNS_SVCPARAM_KEY_DOHPATH 
LDNS_SVCPARAM_KEY_LAST_KEY 
LDNS_SVCPARAM_KEY_RESERVED 

Definition at line 174 of file rdata.h.

Function Documentation

◆ ldns_rdf_set_size()

void ldns_rdf_set_size ( ldns_rdf rd,
size_t  size 
)

sets the size of the rdf.

Parameters
[in]*rdthe rdf to operate on
[in]sizethe new size
Returns
void

Definition at line 46 of file rdata.c.

References ldns_struct_rdf::_size.

◆ ldns_rdf_set_type()

void ldns_rdf_set_type ( ldns_rdf rd,
ldns_rdf_type  type 
)

sets the size of the rdf.

Parameters
[in]*rdthe rdf to operate on
[in]typethe new type
Returns
void

Definition at line 53 of file rdata.c.

References ldns_struct_rdf::_type.

◆ ldns_rdf_set_data()

void ldns_rdf_set_data ( ldns_rdf rd,
void *  data 
)

sets the size of the rdf.

Parameters
[in]*rdthe rdf to operate on
[in]*datapointer to the new data
Returns
void

Definition at line 60 of file rdata.c.

References ldns_struct_rdf::_data.

◆ ldns_rdf_size()

size_t ldns_rdf_size ( const ldns_rdf rd)

returns the size of the rdf.

Parameters
[in]*rdthe rdf to read from
Returns
uint16_t with the size

Definition at line 24 of file rdata.c.

References ldns_struct_rdf::_size.

◆ ldns_rdf_get_type()

ldns_rdf_type ldns_rdf_get_type ( const ldns_rdf rd)

returns the type of the rdf.

We need to insert get here to prevent conflict the the rdf_type TYPE.

Parameters
[in]*rdthe rdf to read from
Returns
ldns_rdf_type with the type

Definition at line 31 of file rdata.c.

References ldns_struct_rdf::_type.

◆ ldns_rdf_data()

uint8_t* ldns_rdf_data ( const ldns_rdf rd)

returns the data of the rdf.

Parameters
[in]*rdthe rdf to read from
Returns
uint8_t* pointer to the rdf's data

Definition at line 38 of file rdata.c.

References ldns_struct_rdf::_data.

◆ 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.

This function DOES NOT copy the contents from the buffer, unlike ldns_rdf_new_frm_data()

Parameters
[in]typetype of the rdf
[in]sizesize of the buffer
[in]datapointer to the buffer to be copied
Returns
the new rdf structure or NULL on failure

Definition at line 179 of file rdata.c.

References LDNS_MALLOC, ldns_rdf_set_data(), ldns_rdf_set_size(), and ldns_rdf_set_type().

◆ 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.

This function does copy the contents from the buffer, unlike ldns_rdf_new()

Parameters
[in]typetype of the rdf
[in]sizesize of the buffer
[in]datapointer to the buffer to be copied
Returns
the new rdf structure or NULL on failure

Definition at line 193 of file rdata.c.

References ldns_struct_rdf::_data, LDNS_FREE, LDNS_MALLOC, LDNS_MAX_RDFLEN, ldns_rdf_set_size(), ldns_rdf_set_type(), and LDNS_XMALLOC.

◆ 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.

Parameters
[in]typetype to use
[in]strstring to use
Returns
ldns_rdf* or NULL in case of an error

Definition at line 249 of file rdata.c.

References LDNS_FREE, ldns_rdf_set_type(), LDNS_RDF_TYPE_A, LDNS_RDF_TYPE_AAAA, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_AMTRELAY, LDNS_RDF_TYPE_APL, LDNS_RDF_TYPE_ATMA, LDNS_RDF_TYPE_B32_EXT, LDNS_RDF_TYPE_B64, LDNS_RDF_TYPE_CERT_ALG, LDNS_RDF_TYPE_CERTIFICATE_USAGE, LDNS_RDF_TYPE_CLASS, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_EUI48, LDNS_RDF_TYPE_EUI64, LDNS_RDF_TYPE_HEX, LDNS_RDF_TYPE_HIP, LDNS_RDF_TYPE_ILNP64, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT32, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_IPSECKEY, LDNS_RDF_TYPE_LOC, LDNS_RDF_TYPE_LONG_STR, LDNS_RDF_TYPE_MATCHING_TYPE, LDNS_RDF_TYPE_NONE, LDNS_RDF_TYPE_NSAP, LDNS_RDF_TYPE_NSEC, LDNS_RDF_TYPE_NSEC3_NEXT_OWNER, LDNS_RDF_TYPE_NSEC3_SALT, LDNS_RDF_TYPE_PERIOD, LDNS_RDF_TYPE_SELECTOR, LDNS_RDF_TYPE_SERVICE, LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_SVCPARAMS, LDNS_RDF_TYPE_TAG, LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_TYPE, LDNS_RDF_TYPE_UNKNOWN, LDNS_RDF_TYPE_WKS, LDNS_STATUS_ERR, LDNS_STATUS_OK, ldns_str2rdf_a(), ldns_str2rdf_aaaa(), ldns_str2rdf_alg(), ldns_str2rdf_amtrelay(), ldns_str2rdf_apl(), ldns_str2rdf_atma(), ldns_str2rdf_b32_ext(), ldns_str2rdf_b64(), ldns_str2rdf_cert_alg(), ldns_str2rdf_certificate_usage(), ldns_str2rdf_class(), ldns_str2rdf_dname(), ldns_str2rdf_eui48(), ldns_str2rdf_eui64(), ldns_str2rdf_hex(), ldns_str2rdf_hip(), ldns_str2rdf_ilnp64(), ldns_str2rdf_int16(), ldns_str2rdf_int32(), ldns_str2rdf_int8(), ldns_str2rdf_ipseckey(), ldns_str2rdf_loc(), ldns_str2rdf_long_str(), ldns_str2rdf_matching_type(), ldns_str2rdf_nsap(), ldns_str2rdf_nsec(), ldns_str2rdf_nsec3_salt(), ldns_str2rdf_period(), ldns_str2rdf_selector(), ldns_str2rdf_service(), ldns_str2rdf_str(), ldns_str2rdf_svcparams(), ldns_str2rdf_tag(), ldns_str2rdf_time(), ldns_str2rdf_type(), ldns_str2rdf_unknown(), and ldns_str2rdf_wks().

◆ ldns_rdf_new_frm_fp()

ldns_status ldns_rdf_new_frm_fp ( ldns_rdf **  r,
ldns_rdf_type  type,
FILE *  fp 
)

creates a new rdf from a file containing a string.

Parameters
[out]rthe new rdf
[in]typetype to use
[in]fpthe file pointer to use
Returns
LDNS_STATUS_OK or the error

Definition at line 386 of file rdata.c.

References ldns_rdf_new_frm_fp_l().

◆ ldns_rdf_new_frm_fp_l()

ldns_status ldns_rdf_new_frm_fp_l ( ldns_rdf **  r,
ldns_rdf_type  type,
FILE *  fp,
int *  line_nr 
)

creates a new rdf from a file containing a string.

Parameters
[out]rthe new rdf
[in]typetype to use
[in]fpthe file pointer to use
[in]line_nrpointer to an integer containing the current line number (for debugging purposes)
Returns
LDNS_STATUS_OK or the error

Definition at line 392 of file rdata.c.

References ldns_fget_token_l(), LDNS_FREE, LDNS_MAX_LINELEN, LDNS_PARSE_SKIP_SPACE, ldns_rdf_new_frm_str(), LDNS_STATUS_MEM_ERR, LDNS_STATUS_NULL, LDNS_STATUS_OK, LDNS_STATUS_SYNTAX_RDATA_ERR, and LDNS_XMALLOC.

◆ ldns_rdf_free()

void ldns_rdf_free ( ldns_rdf rd)

frees a rdf structure, leaving the data pointer intact.

Parameters
[in]rdthe pointer to be freed
Returns
void

Definition at line 241 of file rdata.c.

References LDNS_FREE.

◆ ldns_rdf_deep_free()

void ldns_rdf_deep_free ( ldns_rdf rd)

frees a rdf structure and frees the data.

rdf should be created with _new_frm_data

Parameters
[in]rdthe rdf structure to be freed
Returns
void

Definition at line 230 of file rdata.c.

References ldns_struct_rdf::_data, and LDNS_FREE.

◆ ldns_native2rdf_int8()

ldns_rdf* ldns_native2rdf_int8 ( ldns_rdf_type  type,
uint8_t  value 
)

returns the rdf containing the native uint8_t repr.

Parameters
[in]typethe ldns_rdf type to use
[in]valuethe uint8_t to use
Returns
ldns_rdf* with the converted value

Definition at line 126 of file rdata.c.

References ldns_rdf_new_frm_data(), and LDNS_RDF_SIZE_BYTE.

◆ ldns_native2rdf_int16()

ldns_rdf* ldns_native2rdf_int16 ( ldns_rdf_type  type,
uint16_t  value 
)

returns the rdf containing the native uint16_t representation.

Parameters
[in]typethe ldns_rdf type to use
[in]valuethe uint16_t to use
Returns
ldns_rdf* with the converted value

Definition at line 132 of file rdata.c.

References LDNS_XMALLOC.

◆ ldns_native2rdf_int32()

ldns_rdf* ldns_native2rdf_int32 ( ldns_rdf_type  type,
uint32_t  value 
)

returns an rdf that contains the given int32 value.

Because multiple rdf types can contain an int32, the type must be specified

Parameters
[in]typethe ldns_rdf type to use
[in]valuethe uint32_t to use
Returns
ldns_rdf* with the converted value

Definition at line 147 of file rdata.c.

References LDNS_XMALLOC.

◆ 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 the length.

The memory is copied, and an LDNS_RDF_TYPE_INT16DATA is returned

Parameters
[in]sizethe size of the data
[in]*datapointer to the actual data
Returns
ldns_rd* the rdf with the data

Definition at line 162 of file rdata.c.

References LDNS_XMALLOC.

◆ 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.

The returned rdf has the type LDNS_RDF_TYPE_DNAME!

Parameters
[in]*rdrdf to be reversed
Returns
the reversed rdf (a newly created rdf)

Definition at line 419 of file rdata.c.

References ldns_dname_cat_clone(), ldns_dname_new_frm_str(), LDNS_FREE, ldns_int_to_hexdigit(), LDNS_IP4ADDRLEN, LDNS_IP6ADDRLEN, ldns_rdf2str(), ldns_rdf_data(), ldns_rdf_deep_free(), ldns_rdf_get_type(), ldns_rdf_new_frm_data(), LDNS_RDF_TYPE_A, LDNS_RDF_TYPE_AAAA, and LDNS_XMALLOC.

◆ ldns_rdf2native_int8()

uint8_t ldns_rdf2native_int8 ( const ldns_rdf rd)

returns the native uint8_t representation from the rdf.

Parameters
[in]rdthe ldns_rdf to operate on
Returns
uint8_t the value extracted

Definition at line 70 of file rdata.c.

References ldns_rdf_data(), ldns_rdf_size(), and LDNS_RDF_SIZE_BYTE.

◆ ldns_rdf2native_int16()

uint16_t ldns_rdf2native_int16 ( const ldns_rdf rd)

returns the native uint16_t representation from the rdf.

Parameters
[in]rdthe ldns_rdf to operate on
Returns
uint16_t the value extracted

Definition at line 84 of file rdata.c.

References ldns_rdf_data(), ldns_rdf_size(), and LDNS_RDF_SIZE_WORD.

◆ ldns_rdf2native_int32()

uint32_t ldns_rdf2native_int32 ( const ldns_rdf rd)

returns the native uint32_t representation from the rdf.

Parameters
[in]rdthe ldns_rdf to operate on
Returns
uint32_t the value extracted

Definition at line 98 of file rdata.c.

References ldns_rdf_data(), ldns_rdf_size(), and LDNS_RDF_SIZE_DOUBLEWORD.

◆ ldns_rdf2native_time_t()

time_t ldns_rdf2native_time_t ( const ldns_rdf rd)

returns the native time_t representation from the rdf.

Parameters
[in]rdthe ldns_rdf to operate on
Returns
time_t the value extracted (32 bits currently)

Definition at line 112 of file rdata.c.

References ldns_rdf_data(), ldns_rdf_get_type(), ldns_rdf_size(), LDNS_RDF_SIZE_DOUBLEWORD, and LDNS_RDF_TYPE_TIME.

◆ ldns_str2period()

uint32_t ldns_str2period ( const char *  nptr,
const char **  endptr 
)

converts a ttl value (like 5d2h) to a long.

Parameters
[in]nptrthe start of the string
[out]endptrpoints to the last char in case of error
Returns
the convert duration value

Definition at line 691 of file rdata.c.

◆ ldns_octet()

ldns_status ldns_octet ( char *  word,
size_t *  length 
)

removes \DDD, \[space] and other escapes from the input.

See RFC 1035, section 5.1.

Parameters
[in]wordwhat to check
[in]lengththe string
Returns
ldns_status mesg

Definition at line 595 of file rdata.c.

References LDNS_STATUS_DDD_OVERFLOW, LDNS_STATUS_EMPTY_LABEL, and LDNS_STATUS_OK.

◆ ldns_rdf_clone()

ldns_rdf* ldns_rdf_clone ( const ldns_rdf rd)

clones a rdf structure.

The data is copied.

Parameters
[in]rdrdf to be copied
Returns
a new rdf structure

Definition at line 222 of file rdata.c.

References ldns_rdf_data(), ldns_rdf_get_type(), ldns_rdf_new_frm_data(), and ldns_rdf_size().

◆ ldns_rdf_compare()

int ldns_rdf_compare ( const ldns_rdf rd1,
const ldns_rdf rd2 
)

compares two rdf's on their wire formats.

(To order dnames according to rfc4034, use ldns_dname_compare)

Parameters
[in]rd1the first one
[in]rd2the second one
Returns
0 if equal
-1 if rd1 comes before rd2
+1 if rd2 comes before rd1

Definition at line 657 of file rdata.c.

References ldns_rdf_data(), and ldns_rdf_size().

◆ 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.

Parameters
[in]rdfthe rdf with type LDNS_RDF_TYPE_HIP
[out]algthe algorithm
[out]hit_sizethe size of the HIT data
[out]hitthe hit data
[out]pk_sizethe size of the Public Key data
[out]pkthe Public Key data
Returns
LDNS_STATUS_OK on success, and the error otherwise

Definition at line 537 of file rdata.c.

References ldns_rdf_data(), ldns_rdf_get_type(), ldns_rdf_size(), LDNS_RDF_TYPE_HIP, LDNS_STATUS_INVALID_POINTER, LDNS_STATUS_INVALID_RDF_TYPE, and LDNS_STATUS_WIRE_RDATA_ERR.

◆ 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.

Parameters
[out]rdfthe newly created LDNS_RDF_TYPE_HIP rdf
[in]algthe algorithm
[in]hit_sizethe size of the HIT data
[in]hitthe hit data
[in]pk_sizethe size of the Public Key data
[in]pkthe Public Key data
Returns
LDNS_STATUS_OK on success, and the error otherwise

Definition at line 565 of file rdata.c.

References LDNS_MAX_RDFLEN, LDNS_STATUS_INVALID_POINTER, LDNS_STATUS_MEM_ERR, LDNS_STATUS_RDATA_OVERFLOW, and LDNS_XMALLOC.