ldns documentation

- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

packet.h
Go to the documentation of this file.
1 /*
2 * packet.h
3 *
4 * DNS packet 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
21 #ifndef LDNS_PACKET_H
22 #define LDNS_PACKET_H
23
24 #define LDNS_MAX_PACKETLEN 65535
25
26 /* allow flags to be given to mk_query */
27 #define LDNS_QR 1 /* QueRy - query flag */
28 #define LDNS_AA 2 /* Authoritative Answer - server flag */
29 #define LDNS_TC 4 /* TrunCated - server flag */
30 #define LDNS_RD 8 /* Recursion Desired - query flag */
31 #define LDNS_CD 16 /* Checking Disabled - query flag */
32 #define LDNS_RA 32 /* Recursion Available - server flag */
33 #define LDNS_AD 64 /* Authenticated Data - server flag */
34
35 #include <ldns/error.h>
36 #include <ldns/common.h>
37 #include <ldns/rr.h>
38 #include <sys/time.h>
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 /* opcodes for pkt's */
45 enum ldns_enum_pkt_opcode {
46 LDNS_PACKET_QUERY = 0,
47 LDNS_PACKET_IQUERY = 1,
48 LDNS_PACKET_STATUS = 2, /* there is no 3?? DNS is weird */
49 LDNS_PACKET_NOTIFY = 4,
50 LDNS_PACKET_UPDATE = 5
51 };
52 typedef enum ldns_enum_pkt_opcode ldns_pkt_opcode;
53
54 /* rcodes for pkts */
55 enum ldns_enum_pkt_rcode {
56 LDNS_RCODE_NOERROR = 0,
57 LDNS_RCODE_FORMERR = 1,
58 LDNS_RCODE_SERVFAIL = 2,
59 LDNS_RCODE_NXDOMAIN = 3,
60 LDNS_RCODE_NOTIMPL = 4,
61 LDNS_RCODE_REFUSED = 5,
62 LDNS_RCODE_YXDOMAIN = 6,
63 LDNS_RCODE_YXRRSET = 7,
64 LDNS_RCODE_NXRRSET = 8,
65 LDNS_RCODE_NOTAUTH = 9,
66 LDNS_RCODE_NOTZONE = 10
67 };
68 typedef enum ldns_enum_pkt_rcode ldns_pkt_rcode;
69
192 struct ldns_struct_hdr
193 {
195 uint16_t _id;
197 bool _qr;
199 bool _aa;
201 bool _tc;
203 bool _rd;
205 bool _cd;
207 bool _ra;
209 bool _ad;
211 ldns_pkt_opcode _opcode; /* XXX 8 bits? */
213 uint8_t _rcode;
215 uint16_t _qdcount;
217 uint16_t _ancount;
219 uint16_t _nscount;
221 uint16_t _arcount;
222 };
223 typedef struct ldns_struct_hdr ldns_hdr;
224
233 struct ldns_struct_pkt
234 {
236 ldns_hdr *_header;
237 /* extra items needed in a packet */
239 ldns_rdf *_answerfrom;
241 struct timeval timestamp;
243 uint32_t _querytime;
245 size_t _size;
247 ldns_rr *_tsig_rr;
249 uint16_t _edns_udp_size;
251 uint8_t _edns_extended_rcode;
253 uint8_t _edns_version;
255 uint16_t _edns_z;
257 ldns_rdf *_edns_data;
259 ldns_rr_list *_question;
261 ldns_rr_list *_answer;
263 ldns_rr_list *_authority;
265 ldns_rr_list *_additional;
266 };
267 typedef struct ldns_struct_pkt ldns_pkt;
268
272 enum ldns_enum_pkt_section {
273 LDNS_SECTION_QUESTION = 0,
274 LDNS_SECTION_ANSWER = 1,
275 LDNS_SECTION_AUTHORITY = 2,
276 LDNS_SECTION_ADDITIONAL = 3,
278 LDNS_SECTION_ANY = 4,
280 LDNS_SECTION_ANY_NOQUESTION = 5
281 };
282 typedef enum ldns_enum_pkt_section ldns_pkt_section;
283
287 enum ldns_enum_pkt_type {
288 LDNS_PACKET_QUESTION,
289 LDNS_PACKET_REFERRAL,
290 LDNS_PACKET_ANSWER,
291 LDNS_PACKET_NXDOMAIN,
292 LDNS_PACKET_NODATA,
293 LDNS_PACKET_UNKNOWN
294 };
295 typedef enum ldns_enum_pkt_type ldns_pkt_type;
296
297 /* prototypes */
298
299 /* read */
300
306 uint16_t ldns_pkt_id(const ldns_pkt *p);
312 bool ldns_pkt_qr(const ldns_pkt *p);
318 bool ldns_pkt_aa(const ldns_pkt *p);
324 bool ldns_pkt_tc(const ldns_pkt *p);
330 bool ldns_pkt_rd(const ldns_pkt *p);
336 bool ldns_pkt_cd(const ldns_pkt *p);
342 bool ldns_pkt_ra(const ldns_pkt *p);
348 bool ldns_pkt_ad(const ldns_pkt *p);
354 ldns_pkt_opcode ldns_pkt_get_opcode(const ldns_pkt *p);
360 ldns_pkt_rcode ldns_pkt_get_rcode(const ldns_pkt *p);
366 uint16_t ldns_pkt_qdcount(const ldns_pkt *p);
372 uint16_t ldns_pkt_ancount(const ldns_pkt *p);
378 uint16_t ldns_pkt_nscount(const ldns_pkt *p);
384 uint16_t ldns_pkt_arcount(const ldns_pkt *p);
385
391 ldns_rdf *ldns_pkt_answerfrom(const ldns_pkt *p);
392
398 struct timeval ldns_pkt_timestamp(const ldns_pkt *p);
404 uint32_t ldns_pkt_querytime(const ldns_pkt *p);
405
411 size_t ldns_pkt_size(const ldns_pkt *p);
412
422 uint16_t ldns_pkt_section_count(const ldns_pkt *p, ldns_pkt_section s);
423
429 ldns_rr *ldns_pkt_tsig(const ldns_pkt *p);
430
436 ldns_rr_list *ldns_pkt_question(const ldns_pkt *p);
442 ldns_rr_list *ldns_pkt_answer(const ldns_pkt *p);
448 ldns_rr_list *ldns_pkt_authority(const ldns_pkt *p);
454 ldns_rr_list *ldns_pkt_additional(const ldns_pkt *p);
461 ldns_rr_list *ldns_pkt_all(const ldns_pkt *p);
468 ldns_rr_list *ldns_pkt_all_noquestion(const ldns_pkt *p);
469
477 ldns_rr_list *ldns_pkt_get_section_clone(const ldns_pkt *p, ldns_pkt_section s);
478
487 ldns_rr_list *ldns_pkt_rr_list_by_name(ldns_pkt *p, ldns_rdf *r, ldns_pkt_section s);
496 ldns_rr_list *ldns_pkt_rr_list_by_type(const ldns_pkt *p, ldns_rr_type t, ldns_pkt_section s);
506 ldns_rr_list *ldns_pkt_rr_list_by_name_and_type(const ldns_pkt *packet, const ldns_rdf *ownername, ldns_rr_type type, ldns_pkt_section sec);
507
508
515 bool ldns_pkt_rr(ldns_pkt *pkt, ldns_pkt_section sec, ldns_rr *rr);
516
517
524 bool ldns_pkt_set_flags(ldns_pkt *pkt, uint16_t flags);
525
531 void ldns_pkt_set_id(ldns_pkt *p, uint16_t id);
536 void ldns_pkt_set_random_id(ldns_pkt *p);
542 void ldns_pkt_set_qr(ldns_pkt *p, bool b);
548 void ldns_pkt_set_aa(ldns_pkt *p, bool b);
554 void ldns_pkt_set_tc(ldns_pkt *p, bool b);
560 void ldns_pkt_set_rd(ldns_pkt *p, bool b);
566 void ldns_pkt_set_cd(ldns_pkt *p, bool b);
572 void ldns_pkt_set_ra(ldns_pkt *p, bool b);
578 void ldns_pkt_set_ad(ldns_pkt *p, bool b);
579
585 void ldns_pkt_set_opcode(ldns_pkt *p, ldns_pkt_opcode c);
591 void ldns_pkt_set_rcode(ldns_pkt *p, uint8_t c);
597 void ldns_pkt_set_qdcount(ldns_pkt *p, uint16_t c);
603 void ldns_pkt_set_ancount(ldns_pkt *p, uint16_t c);
609 void ldns_pkt_set_nscount(ldns_pkt *p, uint16_t c);
615 void ldns_pkt_set_arcount(ldns_pkt *p, uint16_t c);
621 void ldns_pkt_set_answerfrom(ldns_pkt *p, ldns_rdf *r);
627 void ldns_pkt_set_querytime(ldns_pkt *p, uint32_t t);
633 void ldns_pkt_set_size(ldns_pkt *p, size_t s);
634
640 void ldns_pkt_set_timestamp(ldns_pkt *p, struct timeval timeval);
647 void ldns_pkt_set_section_count(ldns_pkt *p, ldns_pkt_section s, uint16_t x);
653 void ldns_pkt_set_tsig(ldns_pkt *p, ldns_rr *t);
654
661 ldns_pkt_type ldns_pkt_reply_type(ldns_pkt *p);
662
668 uint16_t ldns_pkt_edns_udp_size(const ldns_pkt *packet);
674 uint8_t ldns_pkt_edns_extended_rcode(const ldns_pkt *packet);
680 uint8_t ldns_pkt_edns_version(const ldns_pkt *packet);
686 uint16_t ldns_pkt_edns_z(const ldns_pkt *packet);
692 ldns_rdf *ldns_pkt_edns_data(const ldns_pkt *packet);
693
699 bool ldns_pkt_edns_do(const ldns_pkt *packet);
705 void ldns_pkt_set_edns_do(ldns_pkt *packet, bool value);
706
716 bool ldns_pkt_edns(const ldns_pkt *packet);
717
723 void ldns_pkt_set_edns_udp_size(ldns_pkt *packet, uint16_t s);
729 void ldns_pkt_set_edns_extended_rcode(ldns_pkt *packet, uint8_t c);
735 void ldns_pkt_set_edns_version(ldns_pkt *packet, uint8_t v);
741 void ldns_pkt_set_edns_z(ldns_pkt *packet, uint16_t z);
747 void ldns_pkt_set_edns_data(ldns_pkt *packet, ldns_rdf *data);
748
753 ldns_pkt *ldns_pkt_new(void);
754
760 void ldns_pkt_free(ldns_pkt *packet);
761
771 ldns_status ldns_pkt_query_new_frm_str(ldns_pkt **p, const char *rr_name, ldns_rr_type rr_type, ldns_rr_class rr_class , uint16_t flags);
772
783 ldns_status ldns_pkt_ixfr_request_new_frm_str(ldns_pkt **p, const char *rr_name, ldns_rr_class rr_class, uint16_t flags, ldns_rr* soa);
784
793 ldns_pkt *ldns_pkt_query_new(ldns_rdf *rr_name, ldns_rr_type rr_type, ldns_rr_class rr_class, uint16_t flags);
794
804 ldns_pkt *ldns_pkt_ixfr_request_new(ldns_rdf *rr_name, ldns_rr_class rr_class, uint16_t flags, ldns_rr* soa);
805
812 ldns_pkt *ldns_pkt_clone(ldns_pkt *pkt);
813
819 void ldns_pkt_set_additional(ldns_pkt *p, ldns_rr_list *rr);
820
826 void ldns_pkt_set_answer(ldns_pkt *p, ldns_rr_list *rr);
827
833 void ldns_pkt_set_question(ldns_pkt *p, ldns_rr_list *rr);
834
840 void ldns_pkt_set_authority(ldns_pkt *p, ldns_rr_list *rr);
841
849 bool ldns_pkt_push_rr(ldns_pkt *packet, ldns_pkt_section section, ldns_rr *rr);
850
858 bool ldns_pkt_safe_push_rr(ldns_pkt *pkt, ldns_pkt_section sec, ldns_rr *rr);
859
867 bool ldns_pkt_push_rr_list(ldns_pkt *packet, ldns_pkt_section section, ldns_rr_list *list);
868
876 bool ldns_pkt_safe_push_rr_list(ldns_pkt *pkt, ldns_pkt_section sec, ldns_rr_list *list);
877
883 bool ldns_pkt_empty(ldns_pkt *p);
884
885 #ifdef __cplusplus
886 }
887 #endif
888
889 #endif /* LDNS_PACKET_H */
ldns_pkt_ra
signed char ldns_pkt_ra(const ldns_pkt *p)
Read the packet&#39;s ra bit.
Definition: packet.c:75
ldns_pkt_answer
ldns_rr_list * ldns_pkt_answer(const ldns_pkt *p)
Return the packet&#39;s answer section.
Definition: packet.c:129
ldns_pkt_get_rcode
ldns_pkt_rcode ldns_pkt_get_rcode(const ldns_pkt *p)
Return the packet&#39;s respons code.
Definition: packet.c:93
ldns_pkt_set_edns_data
void ldns_pkt_set_edns_data(ldns_pkt *packet, ldns_rdf *data)
Set the packet&#39;s edns data.
Definition: packet.c:615
ldns_pkt_type
enum ldns_enum_pkt_type ldns_pkt_type
Definition: packet.h:295
ldns_struct_hdr::_qr
signed char _qr
Query bit (0=query, 1=answer)
Definition: packet.h:197
ldns_struct_hdr::_nscount
uint16_t _nscount
auth sec
Definition: packet.h:219
ldns_pkt_set_random_id
void ldns_pkt_set_random_id(ldns_pkt *p)
Set the packet&#39;s id to a random value.
Definition: packet.c:456
ldns_struct_pkt::_edns_data
ldns_rdf * _edns_data
Arbitrary EDNS rdata.
Definition: packet.h:257
LDNS_RCODE_NOTAUTH
Definition: packet.h:65
ldns_struct_pkt::_answerfrom
ldns_rdf * _answerfrom
The size of the wire format of the packet in octets.
Definition: packet.h:239
ldns_pkt_set_ancount
void ldns_pkt_set_ancount(ldns_pkt *p, uint16_t c)
Set the packet&#39;s an count.
Definition: packet.c:548
LDNS_SECTION_ANSWER
Definition: packet.h:274
ldns_pkt_query_new_frm_str
ldns_status ldns_pkt_query_new_frm_str(ldns_pkt **p, const char *rr_name, ldns_rr_type rr_type, ldns_rr_class rr_class, uint16_t flags)
creates a query packet for the given name, type, class.
Definition: packet.c:967
ldns_pkt_qr
signed char ldns_pkt_qr(const ldns_pkt *p)
Read the packet&#39;s qr bit.
Definition: packet.c:45
ldns_pkt_set_flags
signed char ldns_pkt_set_flags(ldns_pkt *pkt, uint16_t flags)
sets the flags in a packet.
Definition: packet.c:800
ldns_pkt_set_additional
void ldns_pkt_set_additional(ldns_pkt *p, ldns_rr_list *rr)
directly set the additional section
Definition: packet.c:488
ldns_pkt_set_tsig
void ldns_pkt_set_tsig(ldns_pkt *p, ldns_rr *t)
Set the packet&#39;s tsig rr.
Definition: packet.c:642
ldns_rr_class
enum ldns_enum_rr_class ldns_rr_class
Definition: rr.h:64
ldns_struct_rr_list
List or Set of Resource Records.
Definition: rr.h:327
LDNS_RCODE_NXDOMAIN
Definition: packet.h:59
ldns_pkt_set_qdcount
void ldns_pkt_set_qdcount(ldns_pkt *p, uint16_t c)
Set the packet&#39;s qd count.
Definition: packet.c:542
ldns_pkt_set_size
void ldns_pkt_set_size(ldns_pkt *p, size_t s)
Set the packet&#39;s size.
Definition: packet.c:585
ldns_struct_pkt::_authority
ldns_rr_list * _authority
Authority section.
Definition: packet.h:263
ldns_pkt_get_opcode
ldns_pkt_opcode ldns_pkt_get_opcode(const ldns_pkt *p)
Read the packet&#39;s code.
Definition: packet.c:87
ldns_pkt_additional
ldns_rr_list * ldns_pkt_additional(const ldns_pkt *p)
Return the packet&#39;s additional section.
Definition: packet.c:141
ldns_pkt_timestamp
struct timeval ldns_pkt_timestamp(const ldns_pkt *p)
Return the packet&#39;s timestamp.
Definition: packet.c:200
ldns_pkt_tc
signed char ldns_pkt_tc(const ldns_pkt *p)
Read the packet&#39;s tc bit.
Definition: packet.c:57
ldns_struct_hdr::_opcode
ldns_pkt_opcode _opcode
Query type.
Definition: packet.h:211
ldns_struct_hdr::_ra
signed char _ra
Recursion available.
Definition: packet.h:207
LDNS_PACKET_IQUERY
Definition: packet.h:47
ldns_pkt_querytime
uint32_t ldns_pkt_querytime(const ldns_pkt *p)
Return the packet&#39;s querytime.
Definition: packet.c:188
ldns_struct_hdr::_aa
signed char _aa
Authoritative answer.
Definition: packet.h:199
ldns_pkt_edns_udp_size
uint16_t ldns_pkt_edns_udp_size(const ldns_pkt *packet)
return the packet&#39;s edns udp size
Definition: packet.c:206
ldns_pkt_set_ad
void ldns_pkt_set_ad(ldns_pkt *p, signed char b)
Set the packet&#39;s ad bit.
LDNS_PACKET_QUESTION
Definition: packet.h:288
ldns_pkt_set_querytime
void ldns_pkt_set_querytime(ldns_pkt *p, uint32_t t)
Set the packet&#39;s query time.
Definition: packet.c:566
ldns_struct_pkt::_header
ldns_hdr * _header
Header section.
Definition: packet.h:236
ldns_pkt_edns_data
ldns_rdf * ldns_pkt_edns_data(const ldns_pkt *packet)
return the packet&#39;s edns data
Definition: packet.c:246
ldns_enum_pkt_rcode
ldns_enum_pkt_rcode
Definition: packet.h:55
rr.h
Contains the definition of ldns_rr and functions to manipulate those.
LDNS_PACKET_QUERY
Definition: packet.h:46
ldns_pkt_nscount
uint16_t ldns_pkt_nscount(const ldns_pkt *p)
Return the packet&#39;s ns count.
Definition: packet.c:111
ldns_pkt_ixfr_request_new
ldns_pkt * ldns_pkt_ixfr_request_new(ldns_rdf *rr_name, ldns_rr_class rr_class, uint16_t flags, ldns_rr *soa)
creates an IXFR request packet for the given name, type and class.
Definition: packet.c:1042
LDNS_RCODE_NXRRSET
Definition: packet.h:64
ldns_pkt_set_timestamp
void ldns_pkt_set_timestamp(ldns_pkt *p, struct timeval timeval)
Set the packet&#39;s timestamp.
Definition: packet.c:578
LDNS_PACKET_STATUS
Definition: packet.h:48
LDNS_RCODE_YXRRSET
Definition: packet.h:63
ldns_pkt_authority
ldns_rr_list * ldns_pkt_authority(const ldns_pkt *p)
Return the packet&#39;s authority section.
Definition: packet.c:135
ldns_struct_rr
Resource Record.
Definition: rr.h:299
ldns_pkt_rr
signed char ldns_pkt_rr(ldns_pkt *pkt, ldns_pkt_section sec, ldns_rr *rr)
check to see if an rr exist in the packet
Definition: packet.c:357
ldns_struct_pkt::_size
size_t _size
The size of the wire format of the packet in octets.
Definition: packet.h:245
ldns_pkt_question
ldns_rr_list * ldns_pkt_question(const ldns_pkt *p)
Return the packet&#39;s question section.
Definition: packet.c:123
ldns_pkt_safe_push_rr
signed char ldns_pkt_safe_push_rr(ldns_pkt *pkt, ldns_pkt_section sec, ldns_rr *rr)
push an rr on a packet, provided the RR is not there.
Definition: packet.c:684
error.h
Defines error numbers and functions to translate those to a readable string.
ldns_struct_hdr::_cd
signed char _cd
Checking disabled.
Definition: packet.h:205
ldns_pkt_push_rr_list
signed char ldns_pkt_push_rr_list(ldns_pkt *packet, ldns_pkt_section section, ldns_rr_list *list)
push a rr_list on a packet
Definition: packet.c:696
ldns_pkt_tsig
ldns_rr * ldns_pkt_tsig(const ldns_pkt *p)
Return the packet&#39;s tsig pseudo rr&#39;s.
Definition: packet.c:444
ldns_pkt_set_opcode
void ldns_pkt_set_opcode(ldns_pkt *p, ldns_pkt_opcode c)
Set the packet&#39;s opcode.
Definition: packet.c:530
ldns_struct_pkt::_edns_extended_rcode
uint8_t _edns_extended_rcode
EDNS0 Extended rcode.
Definition: packet.h:251
ldns_pkt_set_tc
void ldns_pkt_set_tc(ldns_pkt *p, signed char b)
Set the packet&#39;s tc bit.
ldns_struct_pkt::_answer
ldns_rr_list * _answer
Answer section.
Definition: packet.h:261
ldns_pkt_edns_z
uint16_t ldns_pkt_edns_z(const ldns_pkt *packet)
return the packet&#39;s edns z value
Definition: packet.c:224
ldns_pkt_rd
signed char ldns_pkt_rd(const ldns_pkt *p)
Read the packet&#39;s rd bit.
Definition: packet.c:63
ldns_pkt_opcode
enum ldns_enum_pkt_opcode ldns_pkt_opcode
Definition: packet.h:52
ldns_pkt_set_edns_do
void ldns_pkt_set_edns_do(ldns_pkt *packet, signed char value)
Set the packet&#39;s edns do bit.
ldns_pkt_set_edns_udp_size
void ldns_pkt_set_edns_udp_size(ldns_pkt *packet, uint16_t s)
Set the packet&#39;s edns udp size.
Definition: packet.c:591
ldns_pkt_free
void ldns_pkt_free(ldns_pkt *packet)
frees the packet structure and all data that it contains.
Definition: packet.c:784
ldns_pkt_answerfrom
ldns_rdf * ldns_pkt_answerfrom(const ldns_pkt *p)
Return the packet&#39;s answerfrom.
Definition: packet.c:194
LDNS_SECTION_ANY
bogus section, if not interested
Definition: packet.h:278
ldns_pkt_cd
signed char ldns_pkt_cd(const ldns_pkt *p)
Read the packet&#39;s cd bit.
Definition: packet.c:69
ldns_pkt_set_arcount
void ldns_pkt_set_arcount(ldns_pkt *p, uint16_t c)
Set the packet&#39;s arcount.
Definition: packet.c:560
ldns_pkt_all_noquestion
ldns_rr_list * ldns_pkt_all_noquestion(const ldns_pkt *p)
Return the packet&#39;s answer, authority and additional sections concatenated, in a new rr_list clone...
Definition: packet.c:167
ldns_pkt_set_answerfrom
void ldns_pkt_set_answerfrom(ldns_pkt *p, ldns_rdf *r)
Set the packet&#39;s answering server.
Definition: packet.c:572
ldns_struct_pkt::_querytime
uint32_t _querytime
The duration of the query this packet is an answer to.
Definition: packet.h:243
ldns_pkt_set_rd
void ldns_pkt_set_rd(ldns_pkt *p, signed char b)
Set the packet&#39;s rd bit.
ldns_struct_pkt::_edns_z
uint16_t _edns_z
Reserved EDNS data bits.
Definition: packet.h:255
ldns_struct_pkt::_additional
ldns_rr_list * _additional
Additional section.
Definition: packet.h:265
LDNS_RCODE_SERVFAIL
Definition: packet.h:58
ldns_pkt_edns_do
signed char ldns_pkt_edns_do(const ldns_pkt *packet)
return the packet&#39;s edns do bit
Definition: packet.c:230
ldns_pkt_set_id
void ldns_pkt_set_id(ldns_pkt *p, uint16_t id)
Set the packet&#39;s id.
Definition: packet.c:450
ldns_pkt_new
ldns_pkt * ldns_pkt_new(void)
allocates and initializes a ldns_pkt structure.
Definition: packet.c:732
ldns_struct_hdr::_arcount
uint16_t _arcount
add sec
Definition: packet.h:221
ldns_struct_hdr::_ancount
uint16_t _ancount
answer sec
Definition: packet.h:217
ldns_struct_pkt::_edns_udp_size
uint16_t _edns_udp_size
EDNS0 available buffer size, see RFC2671.
Definition: packet.h:249
ldns_pkt_rcode
enum ldns_enum_pkt_rcode ldns_pkt_rcode
Definition: packet.h:68
LDNS_SECTION_AUTHORITY
Definition: packet.h:275
ldns_struct_hdr::_tc
signed char _tc
Packet truncated.
Definition: packet.h:201
ldns_pkt_set_aa
void ldns_pkt_set_aa(ldns_pkt *p, signed char b)
Set the packet&#39;s aa bit.
ldns_pkt_id
uint16_t ldns_pkt_id(const ldns_pkt *p)
Read the packet id.
Definition: packet.c:39
ldns_pkt_set_edns_extended_rcode
void ldns_pkt_set_edns_extended_rcode(ldns_pkt *packet, uint8_t c)
Set the packet&#39;s edns extended rcode.
Definition: packet.c:597
ldns_pkt_clone
ldns_pkt * ldns_pkt_clone(ldns_pkt *pkt)
clones the given packet, creating a fully allocated copy
Definition: packet.c:1100
ldns_struct_pkt::_question
ldns_rr_list * _question
Question section.
Definition: packet.h:259
ldns_struct_pkt
DNS packet.
Definition: packet.h:233
ldns_pkt_empty
signed char ldns_pkt_empty(ldns_pkt *p)
check if a packet is empty
Definition: packet.c:409
ldns_struct_hdr::_rd
signed char _rd
Recursion desired.
Definition: packet.h:203
ldns_struct_hdr::_ad
signed char _ad
Authentic data.
Definition: packet.h:209
LDNS_PACKET_NODATA
Definition: packet.h:292
ldns_pkt_section_count
uint16_t ldns_pkt_section_count(const ldns_pkt *p, ldns_pkt_section s)
Return the number of RRs in the given section.
Definition: packet.c:383
ldns_pkt_set_answer
void ldns_pkt_set_answer(ldns_pkt *p, ldns_rr_list *rr)
directly set the answer section
Definition: packet.c:500
LDNS_RCODE_YXDOMAIN
Definition: packet.h:62
ldns_pkt_set_qr
void ldns_pkt_set_qr(ldns_pkt *p, signed char b)
Set the packet&#39;s qr bit.
ldns_struct_hdr::_rcode
uint8_t _rcode
Response code.
Definition: packet.h:213
ldns_pkt_get_section_clone
ldns_rr_list * ldns_pkt_get_section_clone(const ldns_pkt *p, ldns_pkt_section s)
return all the rr_list&#39;s in the packet.
Definition: packet.c:423
ldns_pkt_qdcount
uint16_t ldns_pkt_qdcount(const ldns_pkt *p)
Return the packet&#39;s qd count.
Definition: packet.c:99
ldns_status
enum ldns_enum_status ldns_status
Definition: error.h:131
ldns_pkt_edns_extended_rcode
uint8_t ldns_pkt_edns_extended_rcode(const ldns_pkt *packet)
return the packet&#39;s edns extended rcode
Definition: packet.c:212
ldns_pkt_ancount
uint16_t ldns_pkt_ancount(const ldns_pkt *p)
Return the packet&#39;s an count.
Definition: packet.c:105
LDNS_RCODE_REFUSED
Definition: packet.h:61
ldns_pkt_size
size_t ldns_pkt_size(const ldns_pkt *p)
Return the packet&#39;s size in bytes.
Definition: packet.c:182
ldns_pkt_set_cd
void ldns_pkt_set_cd(ldns_pkt *p, signed char b)
Set the packet&#39;s cd bit.
LDNS_PACKET_UNKNOWN
Definition: packet.h:293
ldns_pkt_push_rr
signed char ldns_pkt_push_rr(ldns_pkt *packet, ldns_pkt_section section, ldns_rr *rr)
push an rr on a packet
Definition: packet.c:648
LDNS_PACKET_UPDATE
Definition: packet.h:50
LDNS_PACKET_REFERRAL
Definition: packet.h:289
ldns_struct_hdr::_qdcount
uint16_t _qdcount
question sec
Definition: packet.h:215
ldns_pkt_set_edns_version
void ldns_pkt_set_edns_version(ldns_pkt *packet, uint8_t v)
Set the packet&#39;s edns version.
Definition: packet.c:603
ldns_pkt_ixfr_request_new_frm_str
ldns_status ldns_pkt_ixfr_request_new_frm_str(ldns_pkt **p, const char *rr_name, ldns_rr_class rr_class, uint16_t flags, ldns_rr *soa)
creates an IXFR request packet for the given name, class.
Definition: packet.c:975
ldns_pkt_set_question
void ldns_pkt_set_question(ldns_pkt *p, ldns_rr_list *rr)
directly set the question section
Definition: packet.c:494
ldns_pkt_rr_list_by_name_and_type
ldns_rr_list * ldns_pkt_rr_list_by_name_and_type(const ldns_pkt *packet, const ldns_rdf *ownername, ldns_rr_type type, ldns_pkt_section sec)
return all the rr with a specific type and type from a packet.
Definition: packet.c:320
ldns_struct_rdf
Resource record data field.
Definition: rdata.h:166
LDNS_RCODE_NOERROR
Definition: packet.h:56
ldns_pkt_query_new
ldns_pkt * ldns_pkt_query_new(ldns_rdf *rr_name, ldns_rr_type rr_type, ldns_rr_class rr_class, uint16_t flags)
creates a packet with a query in it for the given name, type and class.
Definition: packet.c:1034
common.h
Common definitions for LDNS.
LDNS_PACKET_NXDOMAIN
Definition: packet.h:291
LDNS_PACKET_NOTIFY
Definition: packet.h:49
ldns_pkt_set_section_count
void ldns_pkt_set_section_count(ldns_pkt *p, ldns_pkt_section s, uint16_t x)
Set a packet&#39;s section count to x.
Definition: packet.c:621
ldns_rr_type
enum ldns_enum_rr_type ldns_rr_type
Definition: rr.h:236
ldns_pkt_rr_list_by_name
ldns_rr_list * ldns_pkt_rr_list_by_name(ldns_pkt *p, ldns_rdf *r, ldns_pkt_section s)
return all the rr with a specific name from a packet.
Definition: packet.c:253
ldns_struct_hdr
Header of a dns packet.
Definition: packet.h:192
ldns_enum_pkt_opcode
ldns_enum_pkt_opcode
Definition: packet.h:45
ldns_pkt_safe_push_rr_list
signed char ldns_pkt_safe_push_rr_list(ldns_pkt *pkt, ldns_pkt_section sec, ldns_rr_list *list)
push an rr_list to a packet, provided the RRs are not already there.
Definition: packet.c:708
ldns_pkt_ad
signed char ldns_pkt_ad(const ldns_pkt *p)
Read the packet&#39;s ad bit.
Definition: packet.c:81
ldns_pkt_set_rcode
void ldns_pkt_set_rcode(ldns_pkt *p, uint8_t c)
Set the packet&#39;s respons code.
Definition: packet.c:536
ldns_pkt_arcount
uint16_t ldns_pkt_arcount(const ldns_pkt *p)
Return the packet&#39;s ar count.
Definition: packet.c:117
ldns_pkt_set_nscount
void ldns_pkt_set_nscount(ldns_pkt *p, uint16_t c)
Set the packet&#39;s ns count.
Definition: packet.c:554
ldns_struct_hdr::_id
uint16_t _id
Id of a packet.
Definition: packet.h:195
ldns_pkt_edns_version
uint8_t ldns_pkt_edns_version(const ldns_pkt *packet)
return the packet&#39;s edns version
Definition: packet.c:218
LDNS_RCODE_FORMERR
Definition: packet.h:57
ldns_pkt_section
enum ldns_enum_pkt_section ldns_pkt_section
Definition: packet.h:282
LDNS_SECTION_ANY_NOQUESTION
used to get all non-question rrs from a packet
Definition: packet.h:280
ldns_pkt_set_ra
void ldns_pkt_set_ra(ldns_pkt *p, signed char b)
Set the packet&#39;s ra bit.
ldns_struct_pkt::_edns_version
uint8_t _edns_version
EDNS Version.
Definition: packet.h:253
ldns_pkt_aa
signed char ldns_pkt_aa(const ldns_pkt *p)
Read the packet&#39;s aa bit.
Definition: packet.c:51
LDNS_PACKET_ANSWER
Definition: packet.h:290
ldns_pkt_set_edns_z
void ldns_pkt_set_edns_z(ldns_pkt *packet, uint16_t z)
Set the packet&#39;s edns z value.
Definition: packet.c:609
ldns_pkt_rr_list_by_type
ldns_rr_list * ldns_pkt_rr_list_by_type(const ldns_pkt *p, ldns_rr_type t, ldns_pkt_section s)
return all the rr with a specific type from a packet.
Definition: packet.c:284
ldns_struct_pkt::_tsig_rr
ldns_rr * _tsig_rr
Optional tsig rr.
Definition: packet.h:247
ldns_pkt_edns
signed char ldns_pkt_edns(const ldns_pkt *packet)
returns true if this packet needs and EDNS rr to be sent.
Definition: packet.c:720
LDNS_SECTION_QUESTION
Definition: packet.h:273
ldns_pkt_set_authority
void ldns_pkt_set_authority(ldns_pkt *p, ldns_rr_list *rr)
directly set the auhority section
Definition: packet.c:506
LDNS_RCODE_NOTIMPL
Definition: packet.h:60
ldns_pkt_all
ldns_rr_list * ldns_pkt_all(const ldns_pkt *p)
Return the packet&#39;s question, answer, authority and additional sections concatenated, in a new rr_list clone.
Definition: packet.c:148
ldns_enum_pkt_type
ldns_enum_pkt_type
The different types of packets.
Definition: packet.h:287
LDNS_SECTION_ADDITIONAL
Definition: packet.h:276
LDNS_RCODE_NOTZONE
Definition: packet.h:66
ldns_pkt_reply_type
ldns_pkt_type ldns_pkt_reply_type(ldns_pkt *p)
looks inside the packet to determine what kind of packet it is, AUTH, NXDOMAIN, REFERRAL, etc.
Definition: packet.c:1054
ldns_enum_pkt_section
ldns_enum_pkt_section
The sections of a packet.
Definition: packet.h:272