wire2host.c
Go to the documentation of this file.
1/*
2 * wire2host.c
3 *
4 * conversion routines from the wire to the host
5 * format.
6 * This will usually just a re-ordering of the
7 * data (as we store it in network format)
8 *
9 * a Net::DNS like library for C
10 *
11 * (c) NLnet Labs, 2004-2006
12 *
13 * See the file LICENSE for the license
14 */
15
16
17#include <ldns/config.h>
18
19#include <ldns/ldns.h>
20/*#include <ldns/wire2host.h>*/
21
22#include <strings.h>
23#include <limits.h>
24
25
26
27/*
28 * Set of macro's to deal with the dns message header as specified
29 * in RFC1035 in portable way.
30 *
31 */
32
33/*
34 *
35 * 1 1 1 1 1 1
36 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
37 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
38 * | ID |
39 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
40 * |QR| Opcode |AA|TC|RD|RA| Z|AD|CD| RCODE |
41 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
42 * | QDCOUNT |
43 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
44 * | ANCOUNT |
45 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
46 * | NSCOUNT |
47 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
48 * | ARCOUNT |
49 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
50 *
51 */
52
53
54/* allocates memory to *dname! */
56ldns_wire2dname(ldns_rdf **dname, const uint8_t *wire, size_t max, size_t *pos)
57{
58 uint8_t label_size;
59 uint16_t pointer_target;
60 uint8_t pointer_target_buf[2];
61 size_t dname_pos = 0;
62 size_t compression_pos = 0;
63 uint8_t tmp_dname[LDNS_MAX_DOMAINLEN];
64 unsigned int pointer_count = 0;
65
66 if (pos == NULL) {
68 }
69 if (*pos >= max) {
71 }
72 label_size = wire[*pos];
73 while (label_size > 0) {
74 /* compression */
75 while (label_size >= 192) {
76 if (compression_pos == 0) {
77 compression_pos = *pos + 2;
78 }
79
80 pointer_count++;
81
82 /* remove first two bits */
83 if (*pos + 2 > max) {
85 }
86 pointer_target_buf[0] = wire[*pos] & 63;
87 pointer_target_buf[1] = wire[*pos + 1];
88 pointer_target = ldns_read_uint16(pointer_target_buf);
89
90 if (pointer_target == 0) {
92 } else if (pointer_target >= max) {
94 } else if (pointer_count > LDNS_MAX_POINTERS) {
96 }
97 *pos = pointer_target;
98 label_size = wire[*pos];
99 }
100 if(label_size == 0)
101 break; /* break from pointer to 0 byte */
102 if (label_size > LDNS_MAX_LABELLEN) {
104 }
105 if (*pos + 1 + label_size > max) {
107 }
108
109 /* check space for labelcount itself */
110 if (dname_pos + 1 > LDNS_MAX_DOMAINLEN) {
112 }
113 tmp_dname[dname_pos] = label_size;
114 if (label_size > 0) {
115 dname_pos++;
116 }
117 *pos = *pos + 1;
118 if (dname_pos + label_size > LDNS_MAX_DOMAINLEN) {
120 }
121 memcpy(&tmp_dname[dname_pos], &wire[*pos], label_size);
122 dname_pos += label_size;
123 *pos = *pos + label_size;
124
125 if (*pos < max) {
126 label_size = wire[*pos];
127 }
128 }
129
130 if (compression_pos > 0) {
131 *pos = compression_pos;
132 } else {
133 *pos = *pos + 1;
134 }
135
136 if (dname_pos >= LDNS_MAX_DOMAINLEN) {
138 }
139
140 tmp_dname[dname_pos] = 0;
141 dname_pos++;
142
144 (uint16_t) dname_pos, tmp_dname);
145 if (!*dname) {
146 return LDNS_STATUS_MEM_ERR;
147 }
148 return LDNS_STATUS_OK;
149}
150
151/* maybe make this a goto error so data can be freed or something/ */
152#define LDNS_STATUS_CHECK_RETURN(st) {if (st != LDNS_STATUS_OK) { return st; }}
153#define LDNS_STATUS_CHECK_GOTO(st, label) {if (st != LDNS_STATUS_OK) { /*printf("STG %s:%d: status code %d\n", __FILE__, __LINE__, st);*/ goto label; }}
154
156ldns_wire2rdf(ldns_rr *rr, const uint8_t *wire, size_t max, size_t *pos)
157{
158 size_t end;
159 size_t cur_rdf_length;
160 uint8_t rdf_index;
161 uint8_t *data;
162 uint16_t rd_length;
163 ldns_rdf *cur_rdf = NULL;
164 ldns_rdf_type cur_rdf_type;
165 const ldns_rr_descriptor *descriptor;
166 ldns_status status;
167
168 assert(rr != NULL);
169
170 descriptor = ldns_rr_descript(ldns_rr_get_type(rr));
171
172 if (*pos + 2 > max) {
174 }
175
176 rd_length = ldns_read_uint16(&wire[*pos]);
177 *pos = *pos + 2;
178
179 if (*pos + rd_length > max) {
181 }
182
183 end = *pos + (size_t) rd_length;
184
185 rdf_index = 0;
186 while (*pos < end &&
187 rdf_index < ldns_rr_descriptor_maximum(descriptor)) {
188
189 cur_rdf_length = 0;
190
191 cur_rdf_type = ldns_rr_descriptor_field_type(
192 descriptor, rdf_index);
193
194 /* handle special cases immediately, set length
195 for fixed length rdata and do them below */
196 switch (cur_rdf_type) {
198 status = ldns_wire2dname(&cur_rdf, wire, max, pos);
200 break;
207 cur_rdf_length = LDNS_RDF_SIZE_BYTE;
208 break;
212 cur_rdf_length = LDNS_RDF_SIZE_WORD;
213 break;
216 case LDNS_RDF_TYPE_A:
218 cur_rdf_length = LDNS_RDF_SIZE_DOUBLEWORD;
219 break;
222 cur_rdf_length = LDNS_RDF_SIZE_6BYTES;
223 break;
228 cur_rdf_length = LDNS_RDF_SIZE_8BYTES;
229 break;
231 cur_rdf_length = LDNS_RDF_SIZE_16BYTES;
232 break;
237 /* len is stored in first byte
238 * it should be in the rdf too, so just
239 * copy len+1 from this position
240 */
241 cur_rdf_length = ((size_t) wire[*pos]) + 1;
242 break;
243
245 if (*pos + 2 > end) {
247 }
248 cur_rdf_length =
249 (size_t) ldns_read_uint16(&wire[*pos]) + 2;
250 break;
252 if (*pos + 4 > end) {
254 }
255 cur_rdf_length =
256 (size_t) wire[*pos] +
257 (size_t) ldns_read_uint16(&wire[*pos + 2]) + 4;
258 break;
261 /* length is stored in first byte */
262 cur_rdf_length = ((size_t) wire[*pos]) + 1;
263 break;
279 /*
280 * Read to end of rr rdata
281 */
282 cur_rdf_length = end - *pos;
283 break;
284 }
285
286 /* fixed length rdata */
287 if (cur_rdf_length > 0) {
288 if (cur_rdf_length + *pos > end) {
290 }
291 data = LDNS_XMALLOC(uint8_t, rd_length);
292 if (!data) {
293 return LDNS_STATUS_MEM_ERR;
294 }
295 memcpy(data, &wire[*pos], cur_rdf_length);
296
297 cur_rdf = ldns_rdf_new(cur_rdf_type,
298 cur_rdf_length, data);
299 *pos = *pos + cur_rdf_length;
300 }
301
302 if (cur_rdf) {
303 ldns_rr_push_rdf(rr, cur_rdf);
304 cur_rdf = NULL;
305 }
306
307 rdf_index++;
308
309 } /* while (rdf_index < ldns_rr_descriptor_maximum(descriptor)) */
310
311
312 return LDNS_STATUS_OK;
313}
314
315/* TODO:
316 can *pos be incremented at READ_INT? or maybe use something like
317 RR_CLASS(wire)?
318 uhhm Jelte??
319*/
321ldns_wire2rr(ldns_rr **rr_p, const uint8_t *wire, size_t max,
322 size_t *pos, ldns_pkt_section section)
323{
324 ldns_rdf *owner = NULL;
325 ldns_rr *rr = ldns_rr_new();
326 ldns_status status;
327
328 status = ldns_wire2dname(&owner, wire, max, pos);
329 LDNS_STATUS_CHECK_GOTO(status, status_error);
330
331 ldns_rr_set_owner(rr, owner);
332
333 if (*pos + 4 > max) {
335 goto status_error;
336 }
337
338 ldns_rr_set_type(rr, ldns_read_uint16(&wire[*pos]));
339 *pos = *pos + 2;
340
341 ldns_rr_set_class(rr, ldns_read_uint16(&wire[*pos]));
342 *pos = *pos + 2;
343
344 if (section != LDNS_SECTION_QUESTION) {
345 if (*pos + 4 > max) {
347 goto status_error;
348 }
349 ldns_rr_set_ttl(rr, ldns_read_uint32(&wire[*pos]));
350
351 *pos = *pos + 4;
352 status = ldns_wire2rdf(rr, wire, max, pos);
353
354 LDNS_STATUS_CHECK_GOTO(status, status_error);
355 ldns_rr_set_question(rr, false);
356 } else {
357 ldns_rr_set_question(rr, true);
358 }
359
360 *rr_p = rr;
361 return LDNS_STATUS_OK;
362
363status_error:
364 ldns_rr_free(rr);
365 return status;
366}
367
368static ldns_status
369ldns_wire2pkt_hdr(ldns_pkt *packet, const uint8_t *wire, size_t max, size_t *pos)
370{
371 if (*pos + LDNS_HEADER_SIZE > max) {
373 } else {
374 ldns_pkt_set_id(packet, LDNS_ID_WIRE(wire));
375 ldns_pkt_set_qr(packet, LDNS_QR_WIRE(wire));
377 ldns_pkt_set_aa(packet, LDNS_AA_WIRE(wire));
378 ldns_pkt_set_tc(packet, LDNS_TC_WIRE(wire));
379 ldns_pkt_set_rd(packet, LDNS_RD_WIRE(wire));
380 ldns_pkt_set_ra(packet, LDNS_RA_WIRE(wire));
381 ldns_pkt_set_ad(packet, LDNS_AD_WIRE(wire));
382 ldns_pkt_set_cd(packet, LDNS_CD_WIRE(wire));
383 ldns_pkt_set_rcode(packet, LDNS_RCODE_WIRE(wire));
384
385 ldns_pkt_set_qdcount(packet, LDNS_QDCOUNT(wire));
386 ldns_pkt_set_ancount(packet, LDNS_ANCOUNT(wire));
387 ldns_pkt_set_nscount(packet, LDNS_NSCOUNT(wire));
388 ldns_pkt_set_arcount(packet, LDNS_ARCOUNT(wire));
389
390 *pos += LDNS_HEADER_SIZE;
391
392 return LDNS_STATUS_OK;
393 }
394}
395
398{
399 /* lazy */
400 return ldns_wire2pkt(packet, ldns_buffer_begin(buffer),
401 ldns_buffer_limit(buffer));
402
403}
404
406ldns_wire2pkt(ldns_pkt **packet_p, const uint8_t *wire, size_t max)
407{
408 size_t pos = 0;
409 uint16_t i;
410 ldns_rr *rr;
411 ldns_pkt *packet = ldns_pkt_new();
413 uint8_t have_edns = 0;
414
415 uint8_t data[4];
416
417 if (!packet) {
418 return LDNS_STATUS_MEM_ERR;
419 }
420
421 status = ldns_wire2pkt_hdr(packet, wire, max, &pos);
422 LDNS_STATUS_CHECK_GOTO(status, status_error);
423
424 for (i = 0; i < ldns_pkt_qdcount(packet); i++) {
425
426 status = ldns_wire2rr(&rr, wire, max, &pos, LDNS_SECTION_QUESTION);
427 if (status == LDNS_STATUS_PACKET_OVERFLOW) {
429 }
430 LDNS_STATUS_CHECK_GOTO(status, status_error);
431 if (!ldns_rr_list_push_rr(ldns_pkt_question(packet), rr)) {
432 ldns_pkt_free(packet);
434 }
435 }
436 for (i = 0; i < ldns_pkt_ancount(packet); i++) {
437 status = ldns_wire2rr(&rr, wire, max, &pos, LDNS_SECTION_ANSWER);
438 if (status == LDNS_STATUS_PACKET_OVERFLOW) {
440 }
441 LDNS_STATUS_CHECK_GOTO(status, status_error);
442 if (!ldns_rr_list_push_rr(ldns_pkt_answer(packet), rr)) {
443 ldns_pkt_free(packet);
445 }
446 }
447 for (i = 0; i < ldns_pkt_nscount(packet); i++) {
448 status = ldns_wire2rr(&rr, wire, max, &pos, LDNS_SECTION_AUTHORITY);
449 if (status == LDNS_STATUS_PACKET_OVERFLOW) {
451 }
452 LDNS_STATUS_CHECK_GOTO(status, status_error);
453 if (!ldns_rr_list_push_rr(ldns_pkt_authority(packet), rr)) {
454 ldns_pkt_free(packet);
456 }
457 }
458 for (i = 0; i < ldns_pkt_arcount(packet); i++) {
459 status = ldns_wire2rr(&rr, wire, max, &pos, LDNS_SECTION_ADDITIONAL);
460 if (status == LDNS_STATUS_PACKET_OVERFLOW) {
462 }
463 LDNS_STATUS_CHECK_GOTO(status, status_error);
464
467 ldns_write_uint32(data, ldns_rr_ttl(rr));
468 ldns_pkt_set_edns_extended_rcode(packet, data[0]);
469 ldns_pkt_set_edns_version(packet, data[1]);
470 ldns_pkt_set_edns_z(packet, ldns_read_uint16(&data[2]));
471 /* edns might not have rdfs */
472 if (ldns_rr_rdf(rr, 0)) {
475 }
476 ldns_rr_free(rr);
477 have_edns += 1;
478 } else if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_TSIG) {
479 ldns_pkt_set_tsig(packet, rr);
480 ldns_pkt_set_arcount(packet, ldns_pkt_arcount(packet) - 1);
481 } else if (!ldns_rr_list_push_rr(ldns_pkt_additional(packet), rr)) {
482 ldns_pkt_free(packet);
484 }
485 }
486 ldns_pkt_set_size(packet, max);
487 if(have_edns)
489 - have_edns);
490 packet->_edns_present = have_edns;
491
492 *packet_p = packet;
493 return status;
494
495status_error:
496 ldns_pkt_free(packet);
497 return status;
498}
@ LDNS_STATUS_WIRE_INCOMPLETE_QUESTION
Definition error.h:73
@ LDNS_STATUS_WIRE_RDATA_ERR
Definition error.h:125
@ LDNS_STATUS_WIRE_INCOMPLETE_ADDITIONAL
Definition error.h:76
@ LDNS_STATUS_WIRE_INCOMPLETE_HEADER
Definition error.h:72
@ LDNS_STATUS_LABEL_OVERFLOW
Definition error.h:28
@ LDNS_STATUS_MEM_ERR
Definition error.h:34
@ LDNS_STATUS_INTERNAL_ERR
Definition error.h:35
@ LDNS_STATUS_WIRE_INCOMPLETE_ANSWER
Definition error.h:74
@ LDNS_STATUS_INVALID_POINTER
Definition error.h:33
@ LDNS_STATUS_WIRE_INCOMPLETE_AUTHORITY
Definition error.h:75
@ LDNS_STATUS_OK
Definition error.h:26
@ LDNS_STATUS_PACKET_OVERFLOW
Definition error.h:32
@ LDNS_STATUS_DOMAINNAME_OVERFLOW
Definition error.h:29
enum ldns_enum_status ldns_status
Definition error.h:149
Including this file will include all ldns files, and define some lookup tables.
void ldns_pkt_free(ldns_pkt *packet)
frees the packet structure and all data that it contains.
Definition packet.c:917
void ldns_pkt_set_ad(ldns_pkt *p, signed char b)
Set the packet's ad bit.
Definition packet.c:564
void ldns_pkt_set_size(ldns_pkt *p, size_t s)
Set the packet's size.
Definition packet.c:625
void ldns_pkt_set_cd(ldns_pkt *p, signed char b)
Set the packet's cd bit.
Definition packet.c:552
void ldns_pkt_set_edns_udp_size(ldns_pkt *packet, uint16_t s)
Set the packet's edns udp size.
Definition packet.c:631
ldns_rr_list * ldns_pkt_additional(const ldns_pkt *p)
Return the packet's additional section.
Definition packet.c:145
ldns_rr_list * ldns_pkt_authority(const ldns_pkt *p)
Return the packet's authority section.
Definition packet.c:139
ldns_rr_list * ldns_pkt_question(const ldns_pkt *p)
Return the packet's question section.
Definition packet.c:127
void ldns_pkt_set_qr(ldns_pkt *p, signed char b)
Set the packet's qr bit.
Definition packet.c:504
uint16_t ldns_pkt_ancount(const ldns_pkt *p)
Return the packet's an count.
Definition packet.c:109
uint16_t ldns_pkt_nscount(const ldns_pkt *p)
Return the packet's ns count.
Definition packet.c:115
void ldns_pkt_set_aa(ldns_pkt *p, signed char b)
Set the packet's aa bit.
Definition packet.c:510
ldns_rr_list * ldns_pkt_answer(const ldns_pkt *p)
Return the packet's answer section.
Definition packet.c:133
void ldns_pkt_set_rd(ldns_pkt *p, signed char b)
Set the packet's rd bit.
Definition packet.c:522
ldns_pkt * ldns_pkt_new(void)
allocates and initializes a ldns_pkt structure.
Definition packet.c:863
void ldns_pkt_set_tc(ldns_pkt *p, signed char b)
Set the packet's tc bit.
Definition packet.c:516
void ldns_pkt_set_rcode(ldns_pkt *p, uint8_t c)
Set the packet's response code.
Definition packet.c:576
void ldns_pkt_set_edns_z(ldns_pkt *packet, uint16_t z)
Set the packet's edns z value.
Definition packet.c:649
enum ldns_enum_pkt_section ldns_pkt_section
Definition packet.h:287
ldns_rdf * ldns_pkt_edns_data(const ldns_pkt *packet)
return the packet's EDNS data
Definition packet.c:279
void ldns_pkt_set_qdcount(ldns_pkt *p, uint16_t c)
Set the packet's qd count.
Definition packet.c:582
uint16_t ldns_pkt_qdcount(const ldns_pkt *p)
Return the packet's qd count.
Definition packet.c:103
void ldns_pkt_set_edns_data(ldns_pkt *packet, ldns_rdf *data)
Set the packet's EDNS data.
Definition packet.c:655
void ldns_pkt_set_arcount(ldns_pkt *p, uint16_t c)
Set the packet's arcount.
Definition packet.c:600
void ldns_pkt_set_opcode(ldns_pkt *p, ldns_pkt_opcode c)
Set the packet's opcode.
Definition packet.c:570
uint16_t ldns_pkt_arcount(const ldns_pkt *p)
Return the packet's ar count.
Definition packet.c:121
void ldns_pkt_set_id(ldns_pkt *p, uint16_t id)
Set the packet's id.
Definition packet.c:490
void ldns_pkt_set_ancount(ldns_pkt *p, uint16_t c)
Set the packet's an count.
Definition packet.c:588
void ldns_pkt_set_ra(ldns_pkt *p, signed char b)
Set the packet's ra bit.
Definition packet.c:558
void ldns_pkt_set_tsig(ldns_pkt *p, ldns_rr *t)
Set the packet's tsig rr.
Definition packet.c:691
void ldns_pkt_set_edns_extended_rcode(ldns_pkt *packet, uint8_t c)
Set the packet's edns extended rcode.
Definition packet.c:637
@ LDNS_SECTION_QUESTION
Definition packet.h:278
@ LDNS_SECTION_ANSWER
Definition packet.h:279
@ LDNS_SECTION_ADDITIONAL
Definition packet.h:281
@ LDNS_SECTION_AUTHORITY
Definition packet.h:280
void ldns_pkt_set_nscount(ldns_pkt *p, uint16_t c)
Set the packet's ns count.
Definition packet.c:594
void ldns_pkt_set_edns_version(ldns_pkt *packet, uint8_t v)
Set the packet's edns version.
Definition packet.c:643
ldns_rdf * ldns_rdf_clone(const ldns_rdf *rd)
clones a rdf structure.
Definition rdata.c:222
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
#define LDNS_RDF_SIZE_WORD
Definition rdata.h:34
void ldns_rdf_deep_free(ldns_rdf *rd)
frees a rdf structure and frees the data.
Definition rdata.c:230
#define LDNS_RDF_SIZE_BYTE
Definition rdata.h:33
#define LDNS_RDF_SIZE_6BYTES
Definition rdata.h:36
#define LDNS_RDF_SIZE_16BYTES
Definition rdata.h:38
#define LDNS_RDF_SIZE_8BYTES
Definition rdata.h:37
@ LDNS_RDF_TYPE_INT32
32 bits
Definition rdata.h:56
@ LDNS_RDF_TYPE_TAG
A non-zero sequence of US-ASCII letters and numbers in lower case.
Definition rdata.h:132
@ LDNS_RDF_TYPE_NSAP
NSAP.
Definition rdata.h:106
@ LDNS_RDF_TYPE_HIP
Represents the Public Key Algorithm, HIT and Public Key fields for the HIP RR types.
Definition rdata.h:95
@ LDNS_RDF_TYPE_IPN
draft-johnson-dns-ipn-cla-07
Definition rdata.h:155
@ LDNS_RDF_TYPE_B32_EXT
b32 string
Definition rdata.h:68
@ LDNS_RDF_TYPE_NSEC3_NEXT_OWNER
nsec3 base32 string (with length byte on wire
Definition rdata.h:114
@ LDNS_RDF_TYPE_CERT_ALG
certificate algorithm
Definition rdata.h:81
@ LDNS_RDF_TYPE_EUI48
6 * 8 bit hex numbers separated by dashes.
Definition rdata.h:122
@ LDNS_RDF_TYPE_SERVICE
protocol and port bitmaps
Definition rdata.h:100
@ LDNS_RDF_TYPE_EUI64
8 * 8 bit hex numbers separated by dashes.
Definition rdata.h:124
@ LDNS_RDF_TYPE_PERIOD
period
Definition rdata.h:89
@ LDNS_RDF_TYPE_B64
b64 string
Definition rdata.h:70
@ LDNS_RDF_TYPE_AAAA
AAAA record.
Definition rdata.h:62
@ LDNS_RDF_TYPE_UNKNOWN
unknown types
Definition rdata.h:85
@ LDNS_RDF_TYPE_WKS
well known services
Definition rdata.h:104
@ LDNS_RDF_TYPE_DNAME
domain name
Definition rdata.h:50
@ LDNS_RDF_TYPE_TIME
time (32 bits)
Definition rdata.h:87
@ LDNS_RDF_TYPE_SVCPARAMS
draft-ietf-dnsop-svcb-https
Definition rdata.h:152
@ LDNS_RDF_TYPE_NSEC
nsec type codes
Definition rdata.h:74
@ LDNS_RDF_TYPE_SELECTOR
Definition rdata.h:145
@ LDNS_RDF_TYPE_NSEC3_SALT
nsec3 hash salt
Definition rdata.h:112
@ LDNS_RDF_TYPE_APL
apl data
Definition rdata.h:66
@ LDNS_RDF_TYPE_A
A record.
Definition rdata.h:60
@ LDNS_RDF_TYPE_LONG_STR
A <character-string> encoding of the value field as specified [RFC1035], Section 5....
Definition rdata.h:138
@ LDNS_RDF_TYPE_LOC
location data
Definition rdata.h:102
@ LDNS_RDF_TYPE_INT64
64 bits
Definition rdata.h:58
@ LDNS_RDF_TYPE_INT16_DATA
variable length any type rdata where the length is specified by the first 2 bytes
Definition rdata.h:98
@ LDNS_RDF_TYPE_ILNP64
4 shorts represented as 4 * 16 bit hex numbers separated by colons.
Definition rdata.h:119
@ LDNS_RDF_TYPE_ATMA
ATMA.
Definition rdata.h:108
@ LDNS_RDF_TYPE_HEX
hex string
Definition rdata.h:72
@ LDNS_RDF_TYPE_NONE
none
Definition rdata.h:48
@ LDNS_RDF_TYPE_CLASS
a class
Definition rdata.h:79
@ LDNS_RDF_TYPE_INT8
8 bits
Definition rdata.h:52
@ LDNS_RDF_TYPE_MATCHING_TYPE
Definition rdata.h:146
@ LDNS_RDF_TYPE_IPSECKEY
IPSECKEY.
Definition rdata.h:110
@ LDNS_RDF_TYPE_CERTIFICATE_USAGE
Since RFC7218 TLSA records can be given with mnemonics, hence these rdata field types.
Definition rdata.h:144
@ LDNS_RDF_TYPE_STR
txt string
Definition rdata.h:64
@ LDNS_RDF_TYPE_INT16
16 bits
Definition rdata.h:54
@ LDNS_RDF_TYPE_ALG
a key algorithm
Definition rdata.h:83
@ LDNS_RDF_TYPE_AMTRELAY
draft-ietf-mboned-driad-amt-discovery
Definition rdata.h:149
@ LDNS_RDF_TYPE_UNQUOTED
Character string without quotes.
Definition rdata.h:127
@ LDNS_RDF_TYPE_TSIGTIME
tsig time 48 bits
Definition rdata.h:91
@ LDNS_RDF_TYPE_TYPE
a RR type
Definition rdata.h:77
#define LDNS_RDF_SIZE_DOUBLEWORD
Definition rdata.h:35
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
enum ldns_enum_rdf_type ldns_rdf_type
Definition rdata.h:157
uint32_t ldns_rr_ttl(const ldns_rr *rr)
returns the ttl of an rr structure.
Definition rr.c:929
void ldns_rr_free(ldns_rr *rr)
frees an RR structure
Definition rr.c:81
void ldns_rr_set_owner(ldns_rr *rr, ldns_rdf *owner)
sets the owner in the rr structure.
Definition rr.c:802
#define LDNS_MAX_LABELLEN
Maximum length of a dname label.
Definition rr.h:31
ldns_rr * ldns_rr_new(void)
creates a new rr structure.
Definition rr.c:30
void ldns_rr_set_type(ldns_rr *rr, ldns_rr_type rr_type)
sets the type in the rr.
Definition rr.c:826
@ LDNS_RR_TYPE_OPT
OPT record RFC 6891.
Definition rr.h:160
@ LDNS_RR_TYPE_TSIG
Definition rr.h:219
signed char ldns_rr_list_push_rr(ldns_rr_list *rr_list, const ldns_rr *rr)
pushes an rr to an rrlist.
Definition rr.c:1130
ldns_rdf_type ldns_rr_descriptor_field_type(const ldns_rr_descriptor *descriptor, size_t field)
returns the rdf type for the given rdata field number of the rr type for the given descriptor.
Definition rr.c:2781
ldns_rdf * ldns_rr_rdf(const ldns_rr *rr, size_t nr)
returns the rdata field member counter.
Definition rr.c:907
ldns_rr_type ldns_rr_get_type(const ldns_rr *rr)
returns the type of the rr.
Definition rr.c:941
void ldns_rr_set_ttl(ldns_rr *rr, uint32_t ttl)
sets the ttl in the rr structure.
Definition rr.c:814
void ldns_rr_set_question(ldns_rr *rr, signed char question)
sets the question flag in the rr structure.
Definition rr.c:808
size_t ldns_rr_descriptor_maximum(const ldns_rr_descriptor *descriptor)
returns the maximum number of rdata fields of the rr type this descriptor describes.
Definition rr.c:2766
ldns_rr_class ldns_rr_get_class(const ldns_rr *rr)
returns the class of the rr.
Definition rr.c:947
#define LDNS_MAX_POINTERS
Maximum number of pointers in 1 dname.
Definition rr.h:35
void ldns_rr_set_class(ldns_rr *rr, ldns_rr_class rr_class)
sets the class in the rr.
Definition rr.c:832
signed char ldns_rr_push_rdf(ldns_rr *rr, const ldns_rdf *f)
sets rd_field member, it will be placed in the next available spot.
Definition rr.c:855
#define LDNS_MAX_DOMAINLEN
Maximum length of a complete dname.
Definition rr.h:33
const ldns_rr_descriptor * ldns_rr_descript(uint16_t type)
returns the resource record descriptor for the given rr type.
Definition rr.c:2737
implementation of buffers to ease operations
Definition buffer.h:51
DNS packet.
Definition packet.h:235
uint8_t _edns_present
Definition packet.h:256
Resource record data field.
Definition rdata.h:203
Contains all information about resource record types.
Definition rr.h:368
Resource Record.
Definition rr.h:327
#define LDNS_XMALLOC(type, count)
Definition util.h:51
ldns_status ldns_wire2dname(ldns_rdf **dname, const uint8_t *wire, size_t max, size_t *pos)
converts the data on the uint8_t bytearray (in wire format) to a DNS dname rdata field.
Definition wire2host.c:56
#define LDNS_STATUS_CHECK_RETURN(st)
Definition wire2host.c:152
ldns_status ldns_wire2rr(ldns_rr **rr_p, const uint8_t *wire, size_t max, size_t *pos, ldns_pkt_section section)
converts the data on the uint8_t bytearray (in wire format) to a DNS resource record.
Definition wire2host.c:321
ldns_status ldns_wire2rdf(ldns_rr *rr, const uint8_t *wire, size_t max, size_t *pos)
converts the data on the uint8_t bytearray (in wire format) to DNS rdata fields, and adds them to the...
Definition wire2host.c:156
#define LDNS_STATUS_CHECK_GOTO(st, label)
Definition wire2host.c:153
ldns_status ldns_buffer2pkt_wire(ldns_pkt **packet, const ldns_buffer *buffer)
converts the data in the ldns_buffer (in wire format) to a DNS packet.
Definition wire2host.c:397
ldns_status ldns_wire2pkt(ldns_pkt **packet_p, const uint8_t *wire, size_t max)
converts the data on the uint8_t bytearray (in wire format) to a DNS packet.
Definition wire2host.c:406
#define LDNS_OPCODE_WIRE(wirebuf)
Definition wire2host.h:55
#define LDNS_ID_WIRE(wirebuf)
Definition wire2host.h:97
#define LDNS_CD_WIRE(wirebuf)
Definition wire2host.h:74
#define LDNS_AD_WIRE(wirebuf)
Definition wire2host.h:80
#define LDNS_AA_WIRE(wirebuf)
Definition wire2host.h:49
#define LDNS_RCODE_WIRE(wirebuf)
Definition wire2host.h:68
#define LDNS_QDCOUNT(wirebuf)
Definition wire2host.h:102
#define LDNS_HEADER_SIZE
Definition wire2host.h:32
#define LDNS_RD_WIRE(wirebuf)
Definition wire2host.h:37
#define LDNS_RA_WIRE(wirebuf)
Definition wire2host.h:92
#define LDNS_NSCOUNT(wirebuf)
Definition wire2host.h:110
#define LDNS_ANCOUNT(wirebuf)
Definition wire2host.h:106
#define LDNS_ARCOUNT(wirebuf)
Definition wire2host.h:114
#define LDNS_QR_WIRE(wirebuf)
Definition wire2host.h:61
#define LDNS_TC_WIRE(wirebuf)
Definition wire2host.h:43