24 #define LDNS_MAX_PACKETLEN 65535
Common definitions for LDNS.
Defines error numbers and functions to translate those to a readable string.
enum ldns_enum_status ldns_status
enum ldns_enum_pkt_type ldns_pkt_type
ldns_pkt * ldns_pkt_clone(const ldns_pkt *pkt)
clones the given packet, creating a fully allocated copy
signed char ldns_pkt_edns(const ldns_pkt *packet)
returns true if this packet needs and EDNS rr to be sent.
void ldns_pkt_free(ldns_pkt *packet)
frees the packet structure and all data that it contains.
uint8_t ldns_pkt_edns_version(const ldns_pkt *packet)
return the packet's edns version
ldns_rr_list * ldns_pkt_get_section_clone(const ldns_pkt *p, ldns_pkt_section s)
return all the rr_list's in the packet.
signed char ldns_pkt_aa(const ldns_pkt *p)
Read the packet's aa bit.
void ldns_pkt_set_ad(ldns_pkt *p, signed char b)
Set the packet's ad bit.
void ldns_pkt_set_timestamp(ldns_pkt *p, struct timeval timeval)
Set the packet's timestamp.
uint16_t ldns_pkt_section_count(const ldns_pkt *p, ldns_pkt_section s)
Return the number of RRs in the given section.
signed char ldns_pkt_set_flags(ldns_pkt *pkt, uint16_t flags)
sets the flags in a packet.
void ldns_pkt_set_size(ldns_pkt *p, size_t s)
Set the packet's size.
void ldns_pkt_set_cd(ldns_pkt *p, signed char b)
Set the packet's cd bit.
size_t ldns_pkt_size(const ldns_pkt *p)
Return the packet's size in bytes.
ldns_rr * ldns_pkt_tsig(const ldns_pkt *p)
Return the packet's tsig pseudo rr's.
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.
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.
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.
signed char ldns_pkt_rr(const ldns_pkt *pkt, ldns_pkt_section sec, const ldns_rr *rr)
check to see if an rr exist in the packet
void ldns_pkt_set_edns_udp_size(ldns_pkt *packet, uint16_t s)
Set the packet's edns udp size.
void ldns_pkt_set_additional(ldns_pkt *p, ldns_rr_list *rr)
directly set the additional section
void ldns_pkt_set_edns_option_list(ldns_pkt *packet, ldns_edns_option_list *list)
Set the packet's structured EDNS data.
ldns_rr_list * ldns_pkt_question(const ldns_pkt *p)
Return the packet's question section.
void ldns_pkt_set_answerfrom(ldns_pkt *p, ldns_rdf *r)
Set the packet's answering server.
ldns_rr_list * ldns_pkt_authority(const ldns_pkt *p)
Return the packet's authority section.
uint32_t ldns_pkt_querytime(const ldns_pkt *p)
Return the packet's querytime.
void ldns_pkt_set_authority(ldns_pkt *p, ldns_rr_list *rr)
directly set the authority section
void ldns_pkt_set_qr(ldns_pkt *p, signed char b)
Set the packet's qr bit.
uint16_t ldns_pkt_ancount(const ldns_pkt *p)
Return the packet's an count.
uint16_t ldns_pkt_nscount(const ldns_pkt *p)
Return the packet's ns count.
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
ldns_rr_list * ldns_pkt_all_noquestion(const ldns_pkt *p)
Return the packet's answer, authority and additional sections concatenated, in a new rr_list clone.
void ldns_pkt_set_aa(ldns_pkt *p, signed char b)
Set the packet's aa bit.
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.
ldns_rdf * ldns_pkt_answerfrom(const ldns_pkt *p)
Return the packet's answerfrom.
ldns_rr_list * ldns_pkt_rr_list_by_name(const ldns_pkt *p, const ldns_rdf *r, ldns_pkt_section s)
return all the rr with a specific name from a packet.
ldns_rr_list * ldns_pkt_answer(const ldns_pkt *p)
Return the packet's answer section.
enum ldns_enum_pkt_rcode ldns_pkt_rcode
ldns_pkt * ldns_pkt_new(void)
allocates and initializes a ldns_pkt structure.
signed char ldns_pkt_empty(ldns_pkt *p)
check if a packet is empty
uint16_t ldns_pkt_id(const ldns_pkt *p)
Read the packet id.
void ldns_pkt_set_rd(ldns_pkt *p, signed char b)
Set the packet's rd bit.
ldns_rr_list * ldns_pkt_all(const ldns_pkt *p)
Return the packet's question, answer, authority and additional sections concatenated,...
signed char ldns_pkt_tc(const ldns_pkt *p)
Read the packet's tc bit.
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.
uint16_t ldns_pkt_edns_unassigned(const ldns_pkt *packet)
return the packet's EDNS header bits that are unassigned.
signed char ldns_pkt_push_rr(ldns_pkt *packet, ldns_pkt_section section, ldns_rr *rr)
push an rr on a packet
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.
void ldns_pkt_set_answer(ldns_pkt *p, ldns_rr_list *rr)
directly set the answer section
void ldns_pkt_set_question(ldns_pkt *p, ldns_rr_list *rr)
directly set the question section
void ldns_pkt_set_tc(ldns_pkt *p, signed char b)
Set the packet's tc bit.
void ldns_pkt_set_edns_do(ldns_pkt *packet, signed char value)
Set the packet's edns do bit.
signed char ldns_pkt_ra(const ldns_pkt *p)
Read the packet's ra bit.
enum ldns_enum_pkt_opcode ldns_pkt_opcode
void ldns_pkt_set_rcode(ldns_pkt *p, uint8_t c)
Set the packet's response code.
void ldns_pkt_set_edns_z(ldns_pkt *packet, uint16_t z)
Set the packet's edns z value.
enum ldns_enum_pkt_section ldns_pkt_section
uint8_t ldns_pkt_edns_extended_rcode(const ldns_pkt *packet)
return the packet's edns extended rcode
void ldns_pkt_set_qdcount(ldns_pkt *p, uint16_t c)
Set the packet's qd count.
uint16_t ldns_pkt_qdcount(const ldns_pkt *p)
Return the packet's qd count.
signed char ldns_pkt_cd(const ldns_pkt *p)
Read the packet's cd bit.
void ldns_pkt_set_edns_data(ldns_pkt *packet, ldns_rdf *data)
Set the packet's EDNS data.
ldns_rr_list * ldns_pkt_additional(const ldns_pkt *p)
Return the packet's additional section.
ldns_pkt_type ldns_pkt_reply_type(const ldns_pkt *p)
looks inside the packet to determine what kind of packet it is, AUTH, NXDOMAIN, REFERRAL,...
void ldns_pkt_set_arcount(ldns_pkt *p, uint16_t c)
Set the packet's arcount.
void ldns_pkt_set_opcode(ldns_pkt *p, ldns_pkt_opcode c)
Set the packet's opcode.
ldns_pkt_opcode ldns_pkt_get_opcode(const ldns_pkt *p)
Read the packet's code.
signed char ldns_pkt_edns_do(const ldns_pkt *packet)
return the packet's edns do bit
uint16_t ldns_pkt_arcount(const ldns_pkt *p)
Return the packet's ar count.
void ldns_pkt_set_id(ldns_pkt *p, uint16_t id)
Set the packet's id.
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.
void ldns_pkt_set_querytime(ldns_pkt *p, uint32_t t)
Set the packet's query time.
void ldns_pkt_set_random_id(ldns_pkt *p)
Set the packet's id to a random value.
void ldns_pkt_set_ancount(ldns_pkt *p, uint16_t c)
Set the packet's an count.
void ldns_pkt_set_ra(ldns_pkt *p, signed char b)
Set the packet's ra bit.
void ldns_pkt_set_tsig(ldns_pkt *p, ldns_rr *t)
Set the packet's tsig rr.
void ldns_pkt_set_edns_extended_rcode(ldns_pkt *packet, uint8_t c)
Set the packet's edns extended rcode.
ldns_rdf * ldns_pkt_edns_data(const ldns_pkt *packet)
return the packet's EDNS data
signed char ldns_pkt_qr(const ldns_pkt *p)
Read the packet's qr bit.
struct timeval ldns_pkt_timestamp(const ldns_pkt *p)
Return the packet's timestamp.
ldns_enum_pkt_section
The sections of a packet.
@ LDNS_SECTION_ANY
bogus section, if not interested
@ LDNS_SECTION_ADDITIONAL
@ LDNS_SECTION_ANY_NOQUESTION
used to get all non-question rrs from a packet
signed char ldns_pkt_rd(const ldns_pkt *p)
Read the packet's rd bit.
signed char ldns_pkt_ad(const ldns_pkt *p)
Read the packet's ad bit.
void ldns_pkt_set_nscount(ldns_pkt *p, uint16_t c)
Set the packet's ns count.
uint16_t ldns_pkt_edns_z(const ldns_pkt *packet)
return the packet's edns z value
void ldns_pkt_set_section_count(ldns_pkt *p, ldns_pkt_section s, uint16_t x)
Set a packet's section count to x.
ldns_edns_option_list * ldns_pkt_edns_get_option_list(ldns_pkt *packet)
Returns a list of structured EDNS options.
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.
ldns_enum_pkt_type
The different types of packets.
ldns_pkt_rcode ldns_pkt_get_rcode(const ldns_pkt *p)
Return the packet's response code.
uint16_t ldns_pkt_edns_udp_size(const ldns_pkt *packet)
return the packet's edns udp size
void ldns_pkt_set_edns_version(ldns_pkt *packet, uint8_t v)
Set the packet's edns version.
void ldns_pkt_set_edns_unassigned(ldns_pkt *packet, uint16_t value)
Set the packet's EDNS header bits that are unassigned.
Contains the definition of ldns_rr and functions to manipulate those.
enum ldns_enum_rr_type ldns_rr_type
enum ldns_enum_rr_class ldns_rr_class
signed char _rd
Recursion desired.
uint16_t _id
Id of a packet.
ldns_pkt_opcode _opcode
Query type.
signed char _cd
Checking disabled.
signed char _ra
Recursion available.
uint16_t _ancount
answer sec
signed char _qr
Query bit (0=query, 1=answer)
signed char _tc
Packet truncated.
signed char _ad
Authentic data.
uint16_t _qdcount
question sec
uint8_t _rcode
Response code.
uint16_t _nscount
auth sec
signed char _aa
Authoritative answer.
struct timeval timestamp
Timestamp of the time the packet was sent or created.
uint8_t _edns_extended_rcode
EDNS0 Extended rcode.
ldns_rr_list * _authority
Authority section.
ldns_hdr * _header
Header section.
uint32_t _querytime
The duration of the query this packet is an answer to.
uint16_t _edns_udp_size
EDNS0 available buffer size, see RFC2671.
ldns_rdf * _answerfrom
an rdf (A or AAAA) with the IP address of the server it is from
uint8_t _edns_version
EDNS Version.
size_t _size
The size of the wire format of the packet in octets.
ldns_rr_list * _answer
Answer section.
ldns_rdf * _edns_data
Arbitrary EDNS rdata.
ldns_edns_option_list * _edns_list
Structed EDNS data.
uint16_t _edns_z
Reserved EDNS data bits.
ldns_rr_list * _additional
Additional section.
ldns_rr * _tsig_rr
Optional tsig rr.
ldns_rr_list * _question
Question section.
Resource record data field.
List or Set of Resource Records.