ldns  1.7.0
rdata.h
Go to the documentation of this file.
1 /*
2  * rdata.h
3  *
4  * rdata definitions
5  *
6  * a Net::DNS like library for C
7  *
8  * (c) NLnet Labs, 2005-2006
9  *
10  * See the file LICENSE for the license
11  */
12 
13 
21 #ifndef LDNS_RDATA_H
22 #define LDNS_RDATA_H
23 
24 #include <ldns/common.h>
25 #include <ldns/error.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #define LDNS_MAX_RDFLEN 65535
32 
33 #define LDNS_RDF_SIZE_BYTE 1
34 #define LDNS_RDF_SIZE_WORD 2
35 #define LDNS_RDF_SIZE_DOUBLEWORD 4
36 #define LDNS_RDF_SIZE_6BYTES 6
37 #define LDNS_RDF_SIZE_8BYTES 8
38 #define LDNS_RDF_SIZE_16BYTES 16
39 
40 #define LDNS_NSEC3_VARS_OPTOUT_MASK 0x01
41 
46 {
112 
117 
122 
127 
133 
141 
144 
145  /* Aliases */
147 };
149 
154 {
165 };
167 
168 
169 
178 {
180  size_t _size;
184  void *_data;
185 };
186 typedef struct ldns_struct_rdf ldns_rdf;
187 
188 /* prototypes */
189 
190 /* write access functions */
191 
198 void ldns_rdf_set_size(ldns_rdf *rd, size_t size);
199 
207 
214 void ldns_rdf_set_data(ldns_rdf *rd, void *data);
215 
216 /* read access */
217 
223 size_t ldns_rdf_size(const ldns_rdf *rd);
224 
232 
239 uint8_t *ldns_rdf_data(const ldns_rdf *rd);
240 
241 /* creator functions */
242 
252 ldns_rdf *ldns_rdf_new(ldns_rdf_type type, size_t size, void *data);
253 
263 ldns_rdf *ldns_rdf_new_frm_data(ldns_rdf_type type, size_t size, const void *data);
264 
271 ldns_rdf *ldns_rdf_new_frm_str(ldns_rdf_type type, const char *str);
272 
281 
290 ldns_status ldns_rdf_new_frm_fp_l(ldns_rdf **r, ldns_rdf_type type, FILE *fp, int *line_nr);
291 
292 /* destroy functions */
293 
300 void ldns_rdf_free(ldns_rdf *rd);
301 
308 void ldns_rdf_deep_free(ldns_rdf *rd);
309 
310 /* conversion functions */
311 
318 ldns_rdf *ldns_native2rdf_int8(ldns_rdf_type type, uint8_t value);
319 
326 ldns_rdf *ldns_native2rdf_int16(ldns_rdf_type type, uint16_t value);
327 
337 ldns_rdf *ldns_native2rdf_int32(ldns_rdf_type type, uint32_t value);
338 
349 ldns_rdf *ldns_native2rdf_int16_data(size_t size, uint8_t *data);
350 
358 
364 uint8_t ldns_rdf2native_int8(const ldns_rdf *rd);
365 
371 uint16_t ldns_rdf2native_int16(const ldns_rdf *rd);
372 
378 uint32_t ldns_rdf2native_int32(const ldns_rdf *rd);
379 
385 time_t ldns_rdf2native_time_t(const ldns_rdf *rd);
386 
393 uint32_t ldns_str2period(const char *nptr, const char **endptr);
394 
402 ldns_status ldns_octet(char *word, size_t *length);
403 
409 ldns_rdf *ldns_rdf_clone(const ldns_rdf *rd);
410 
420 int ldns_rdf_compare(const ldns_rdf *rd1, const ldns_rdf *rd2);
421 
434  uint8_t *hit_size, uint8_t** hit,
435  uint16_t *pk_size, uint8_t** pk);
436 
448  uint8_t hit_size, uint8_t *hit, uint16_t pk_size, uint8_t *pk);
449 
450 #ifdef __cplusplus
451 }
452 #endif
453 
454 #endif /* LDNS_RDATA_H */
int ldns_rdf_compare(const ldns_rdf *rd1, const ldns_rdf *rd2)
compares two rdf's on their wire formats.
Definition: rdata.c:654
uint8_t ldns_rdf2native_int8(const ldns_rdf *rd)
returns the native uint8_t representation from the rdf.
Definition: rdata.c:70
void ldns_rdf_free(ldns_rdf *rd)
frees a rdf structure, leaving the data pointer intact.
Definition: rdata.c:241
enum ldns_enum_cert_algorithm ldns_cert_algorithm
Definition: rdata.h:166
time (32 bits)
Definition: rdata.h:84
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 * 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
b64 string
Definition: rdata.h:68
ldns_rdf_type ldns_rdf_get_type(const ldns_rdf *rd)
returns the type of the rdf.
Definition: rdata.c:31
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:389
unknown types
Definition: rdata.h:82
time_t ldns_rdf2native_time_t(const ldns_rdf *rd)
returns the native time_t representation from the rdf.
Definition: rdata.c:112
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:534
a RR type
Definition: rdata.h:74
void ldns_rdf_set_size(ldns_rdf *rd, size_t size)
sets the size of the rdf.
Definition: rdata.c:46
uint8_t * ldns_rdf_data(const ldns_rdf *rd)
returns the data of the rdf.
Definition: rdata.c:38
ldns_enum_rdf_type
The different types of RDATA fields.
Definition: rdata.h:45
protocol and port bitmaps
Definition: rdata.h:97
A non-zero sequence of US-ASCII letters and numbers in lower case.
Definition: rdata.h:126
A <character-string> encoding of the value field as specified [RFC1035], Section 5....
Definition: rdata.h:132
apl data
Definition: rdata.h:64
size_t ldns_rdf_size(const ldns_rdf *rd)
returns the size of the rdf.
Definition: rdata.c:24
ldns_enum_cert_algorithm
algorithms used in CERT rrs
Definition: rdata.h:153
uint32_t ldns_str2period(const char *nptr, const char **endptr)
converts a ttl value (like 5d2h) to a long.
Definition: rdata.c:688
void ldns_rdf_set_type(ldns_rdf *rd, ldns_rdf_type type)
sets the size of the rdf.
Definition: rdata.c:53
certificate algorithm
Definition: rdata.h:78
Defines error numbers and functions to translate those to a readable string.
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 * ldns_rdf_new_frm_str(ldns_rdf_type type, const char *str)
creates a new rdf from a string.
Definition: rdata.c:249
enum ldns_enum_rdf_type ldns_rdf_type
Definition: rdata.h:148
Since RFC7218 TLSA records can be given with mnemonics, hence these rdata field types.
Definition: rdata.h:138
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
void * _data
Pointer to the data (raw octets)
Definition: rdata.h:184
draft-ietf-mboned-driad-amt-discovery
Definition: rdata.h:143
variable length any type rdata where the length is specified by the first 2 bytes
Definition: rdata.h:95
a key algorithm
Definition: rdata.h:80
b32 string
Definition: rdata.h:66
A record.
Definition: rdata.h:58
uint32_t ldns_rdf2native_int32(const ldns_rdf *rd)
returns the native uint32_t representation from the rdf.
Definition: rdata.c:98
nsec type codes
Definition: rdata.h:72
AAAA record.
Definition: rdata.h:60
ldns_rdf * ldns_rdf_clone(const ldns_rdf *rd)
clones a rdf structure.
Definition: rdata.c:222
void ldns_rdf_deep_free(ldns_rdf *rd)
frees a rdf structure and frees the data.
Definition: rdata.c:230
ldns_rdf * ldns_rdf_address_reverse(const ldns_rdf *rd)
reverses an rdf, only actually useful for AAAA and A records.
Definition: rdata.c:416
hex string
Definition: rdata.h:70
ldns_status ldns_octet(char *word, size_t *length)
removes \DDD, \[space] and other escapes from the input.
Definition: rdata.c:592
txt string
Definition: rdata.h:62
tsig time 48 bits
Definition: rdata.h:88
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:562
nsec3 base32 string (with length byte on wire
Definition: rdata.h:111
enum ldns_enum_status ldns_status
Definition: error.h:134
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
size_t _size
The size of the data (in octets)
Definition: rdata.h:180
4 shorts represented as 4 * 16 bit hex numbers separated by colons.
Definition: rdata.h:116
Resource record data field.
Definition: rdata.h:177
Represents the Public Key Algorithm, HIT and Public Key fields for the HIP RR types.
Definition: rdata.h:92
Common definitions for LDNS.
void ldns_rdf_set_data(ldns_rdf *rd, void *data)
sets the size of the rdf.
Definition: rdata.c:60
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
nsec3 hash salt
Definition: rdata.h:109
ldns_rdf_type _type
The type of the data.
Definition: rdata.h:182
domain name
Definition: rdata.h:50
location data
Definition: rdata.h:99
8 * 8 bit hex numbers separated by dashes.
Definition: rdata.h:121
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:383
6 * 8 bit hex numbers separated by dashes.
Definition: rdata.h:119
well known services
Definition: rdata.h:101
uint16_t ldns_rdf2native_int16(const ldns_rdf *rd)
returns the native uint16_t representation from the rdf.
Definition: rdata.c:84