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 8192
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_16BYTES 16
38 
39 #define LDNS_NSEC3_VARS_OPTOUT_MASK 0x01
40 
45 {
108 };
110 
115 {
126 };
128 
129 
130 
139 {
141  size_t _size;
143  ldns_rdf_type _type;
145  void *_data;
146 };
147 typedef struct ldns_struct_rdf ldns_rdf;
148 
149 /* prototypes */
150 
151 /* write access functions */
152 
159 void ldns_rdf_set_size(ldns_rdf *rd, size_t size);
160 
167 void ldns_rdf_set_type(ldns_rdf *rd, ldns_rdf_type type);
168 
175 void ldns_rdf_set_data(ldns_rdf *rd, void *data);
176 
177 /* read access */
178 
184 size_t ldns_rdf_size(const ldns_rdf *rd);
185 
192 ldns_rdf_type ldns_rdf_get_type(const ldns_rdf *rd);
193 
200 uint8_t *ldns_rdf_data(const ldns_rdf *rd);
201 
202 /* creator functions */
203 
213 ldns_rdf *ldns_rdf_new(ldns_rdf_type type, size_t size, void *data);
214 
224 ldns_rdf *ldns_rdf_new_frm_data(ldns_rdf_type type, size_t size, const void *data);
225 
232 ldns_rdf *ldns_rdf_new_frm_str(ldns_rdf_type type, const char *str);
233 
241 ldns_status ldns_rdf_new_frm_fp(ldns_rdf **r, ldns_rdf_type type, FILE *fp);
242 
251 ldns_status ldns_rdf_new_frm_fp_l(ldns_rdf **r, ldns_rdf_type type, FILE *fp, int *line_nr);
252 
253 /* destroy functions */
254 
261 void ldns_rdf_free(ldns_rdf *rd);
262 
269 void ldns_rdf_deep_free(ldns_rdf *rd);
270 
271 /* conversion functions */
272 
279 ldns_rdf *ldns_native2rdf_int8(ldns_rdf_type type, uint8_t value);
280 
287 ldns_rdf *ldns_native2rdf_int16(ldns_rdf_type type, uint16_t value);
288 
298 ldns_rdf *ldns_native2rdf_int32(ldns_rdf_type type, uint32_t value);
299 
310 ldns_rdf *ldns_native2rdf_int16_data(size_t size, uint8_t *data);
311 
319 
325 uint8_t ldns_rdf2native_int8(const ldns_rdf *rd);
326 
332 uint16_t ldns_rdf2native_int16(const ldns_rdf *rd);
333 
339 uint32_t ldns_rdf2native_int32(const ldns_rdf *rd);
340 
346 time_t ldns_rdf2native_time_t(const ldns_rdf *rd);
347 
354 uint32_t ldns_str2period(const char *nptr, const char **endptr);
355 
363 ldns_status ldns_octet(char *word, size_t *length);
364 
370 ldns_rdf *ldns_rdf_clone(const ldns_rdf *rd);
371 
381 int ldns_rdf_compare(const ldns_rdf *rd1, const ldns_rdf *rd2);
382 
383 #ifdef __cplusplus
384 }
385 #endif
386 
387 #endif /* LDNS_RDATA_H */