rdata.h
Go to the documentation of this file.
/*
* rdata.h
*
* rdata definitions
*
* a Net::DNS like library for C
*
* (c) NLnet Labs, 2005-2006
*
* See the file LICENSE for the license
*/
#ifndef LDNS_RDATA_H
#define LDNS_RDATA_H
#include <ldns/common.h>
#include <ldns/error.h>
#ifdef __cplusplus
extern "C" {
#endif
#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
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,
/* Aliases */
LDNS_RDF_TYPE_BITMAP = LDNS_RDF_TYPE_NSEC
};
typedef enum ldns_enum_rdf_type ldns_rdf_type;
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
};
typedef enum ldns_enum_cert_algorithm ldns_cert_algorithm;
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
};
typedef enum ldns_enum_svcparam_key ldns_svcparam_key;
struct ldns_struct_rdf
{
size_t _size;
ldns_rdf_type _type;
void *_data;
};
typedef struct ldns_struct_rdf ldns_rdf;
/* prototypes */
/* write access functions */
void ldns_rdf_set_size(ldns_rdf *rd, size_t size);
void ldns_rdf_set_type(ldns_rdf *rd, ldns_rdf_type type);
void ldns_rdf_set_data(ldns_rdf *rd, void *data);
/* read access */
size_t ldns_rdf_size(const ldns_rdf *rd);
ldns_rdf_type ldns_rdf_get_type(const ldns_rdf *rd);
uint8_t *ldns_rdf_data(const ldns_rdf *rd);
/* creator functions */
ldns_rdf *ldns_rdf_new(ldns_rdf_type type, size_t size, void *data);
ldns_rdf *ldns_rdf_new_frm_data(ldns_rdf_type type, size_t size, const void *data);
ldns_rdf *ldns_rdf_new_frm_str(ldns_rdf_type type, const char *str);
ldns_status ldns_rdf_new_frm_fp(ldns_rdf **r, ldns_rdf_type type, FILE *fp);
ldns_status ldns_rdf_new_frm_fp_l(ldns_rdf **r, ldns_rdf_type type, FILE *fp, int *line_nr);
/* destroy functions */
void ldns_rdf_free(ldns_rdf *rd);
void ldns_rdf_deep_free(ldns_rdf *rd);
/* conversion functions */
ldns_rdf *ldns_native2rdf_int8(ldns_rdf_type type, uint8_t value);
ldns_rdf *ldns_native2rdf_int16(ldns_rdf_type type, uint16_t value);
ldns_rdf *ldns_native2rdf_int32(ldns_rdf_type type, uint32_t value);
ldns_rdf *ldns_native2rdf_int16_data(size_t size, uint8_t *data);
ldns_rdf *ldns_rdf_address_reverse(const ldns_rdf *rd);
uint8_t ldns_rdf2native_int8(const ldns_rdf *rd);
uint16_t ldns_rdf2native_int16(const ldns_rdf *rd);
uint32_t ldns_rdf2native_int32(const ldns_rdf *rd);
time_t ldns_rdf2native_time_t(const ldns_rdf *rd);
uint32_t ldns_str2period(const char *nptr, const char **endptr);
ldns_status ldns_octet(char *word, size_t *length);
ldns_rdf *ldns_rdf_clone(const ldns_rdf *rd);
int ldns_rdf_compare(const ldns_rdf *rd1, const ldns_rdf *rd2);
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);
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);
#ifdef __cplusplus
}
#endif
#endif /* LDNS_RDATA_H */
common.h
Common definitions for LDNS.
error.h
Defines error numbers and functions to translate those to a readable string.
ldns_status
enum ldns_enum_status ldns_status
Definition error.h:148
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_cert_algorithm
enum ldns_enum_cert_algorithm ldns_cert_algorithm
Definition rdata.h:169
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_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.
Definition rdata.c:392
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_svcparam_key
enum ldns_enum_svcparam_key ldns_svcparam_key
Definition rdata.h:187
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_enum_rdf_type
ldns_enum_rdf_type
The different types of RDATA fields.
Definition rdata.h:46
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_BITMAP
@ LDNS_RDF_TYPE_BITMAP
Definition rdata.h:149
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_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_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.
Definition rdata.c:386
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_enum_svcparam_key
ldns_enum_svcparam_key
keys types in SVCPARAMS rdata fields
Definition rdata.h:175
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_RESERVED
@ LDNS_SVCPARAM_KEY_RESERVED
Definition rdata.h:185
LDNS_SVCPARAM_KEY_LAST_KEY
@ LDNS_SVCPARAM_KEY_LAST_KEY
Definition rdata.h:184
LDNS_SVCPARAM_KEY_NO_DEFAULT_ALPN
@ LDNS_SVCPARAM_KEY_NO_DEFAULT_ALPN
Definition rdata.h:178
LDNS_SVCPARAM_KEY_DOHPATH
@ LDNS_SVCPARAM_KEY_DOHPATH
Definition rdata.h:183
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_enum_cert_algorithm
ldns_enum_cert_algorithm
algorithms used in CERT rrs
Definition rdata.h:157
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_rdf_type
enum ldns_enum_rdf_type ldns_rdf_type
Definition rdata.h:151
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