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