 |
ldns
1.7.0
|
Go to the documentation of this file.
21 #include <openssl/rand.h>
28 #define LDNS_EDNS_MASK_DO_BIT 0x8000
184 return packet->
_size;
202 return packet->timestamp;
586 packet->
timestamp.tv_sec = timeval.tv_sec;
587 packet->
timestamp.tv_usec = timeval.tv_usec;
917 ldns_pkt_query_new_frm_str_internal(
ldns_pkt **p,
const char *name,
978 return ldns_pkt_query_new_frm_str_internal(p, name, rr_type,
979 rr_class, flags, NULL);
990 authsoa_rr = ldns_pkt_authsoa(name_rdf, rr_class);
995 rr_class, flags, authsoa_rr);
1023 if (rr_class == 0) {
1045 return ldns_pkt_query_new_internal(rr_name, rr_type,
1046 rr_class, flags, NULL);
1055 authsoa_rr = ldns_pkt_authsoa(rr_name, rr_class);
1058 rr_class, flags, authsoa_rr);
List or Set of Resource Records.
ldns_rdf * ldns_pkt_edns_data(const ldns_pkt *packet)
return the packet's edns data
enum ldns_enum_rr_class ldns_rr_class
bool ldns_pkt_edns_do(const ldns_pkt *packet)
return the packet's edns do bit
void ldns_pkt_set_qr(ldns_pkt *packet, bool qr)
uint16_t ldns_pkt_section_count(const ldns_pkt *packet, ldns_pkt_section s)
Return the number of RRs in the given section.
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.
@ LDNS_RDF_TYPE_INT32
32 bits
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.
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.
ldns_rdf * ldns_native2rdf_int32(ldns_rdf_type type, uint32_t value)
returns an rdf that contains the given int32 value.
uint32_t _querytime
The duration of the query this packet is an answer to.
void ldns_pkt_set_timestamp(ldns_pkt *packet, struct timeval timeval)
signed char _rd
Recursion desired.
uint16_t ldns_pkt_edns_z(const ldns_pkt *packet)
return the packet's edns z value
#define LDNS_EDNS_MASK_DO_BIT
uint16_t ldns_pkt_id(const ldns_pkt *packet)
Read the packet id.
ldns_lookup_table ldns_edns_flags[]
EDNS flags.
signed char _ra
Recursion available.
ldns_rr_list * ldns_pkt_question(const ldns_pkt *packet)
Return the packet's question section.
void ldns_pkt_set_edns_extended_rcode(ldns_pkt *packet, uint8_t c)
Set the packet's edns extended rcode.
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.
ldns_pkt_opcode ldns_pkt_get_opcode(const ldns_pkt *packet)
Read the packet's code.
void ldns_pkt_set_edns_z(ldns_pkt *packet, uint16_t z)
Set the packet's edns z value.
ldns_rr_list * ldns_pkt_all(const ldns_pkt *packet)
Return the packet's question, answer, authority and additional sections concatenated,...
signed char _tc
Packet truncated.
bool ldns_rr_list_push_rr(ldns_rr_list *rr_list, const ldns_rr *rr)
pushes an rr to an rrlist.
uint16_t ldns_pkt_qdcount(const ldns_pkt *packet)
Return the packet's qd count.
void ldns_pkt_set_edns_version(ldns_pkt *packet, uint8_t v)
Set the packet's edns version.
void ldns_pkt_set_cd(ldns_pkt *packet, bool cd)
@ LDNS_RR_CLASS_IN
the Internet
void ldns_rr_set_class(ldns_rr *rr, ldns_rr_class rr_class)
sets the class in the rr.
void ldns_pkt_set_querytime(ldns_pkt *packet, uint32_t time)
Set the packet's query time.
void ldns_rr_set_question(ldns_rr *rr, bool question)
void ldns_pkt_set_tsig(ldns_pkt *pkt, ldns_rr *rr)
Set the packet's tsig rr.
ldns_rdf * _edns_data
Arbitrary EDNS rdata.
enum ldns_enum_pkt_opcode ldns_pkt_opcode
ldns_rr * ldns_rr_new(void)
creates a new rr structure.
void ldns_rr_list_deep_free(ldns_rr_list *rr_list)
frees an rr_list structure and all rrs contained therein.
uint32_t ldns_pkt_querytime(const ldns_pkt *packet)
Return the packet's querytime.
uint16_t _ancount
answer sec
ldns_rr_list * _question
Question section.
bool ldns_pkt_aa(const ldns_pkt *packet)
Read the packet's aa bit.
signed char _cd
Checking disabled.
ldns_rr_list * ldns_pkt_rr_list_by_name(const ldns_pkt *packet, const ldns_rdf *ownername, ldns_pkt_section sec)
return all the rr with a specific name from a packet.
void ldns_pkt_set_nscount(ldns_pkt *packet, uint16_t nscount)
Set the packet's ns count.
ldns_rr_list * _answer
Answer section.
ldns_rr * _tsig_rr
Optional tsig rr.
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.
ldns_pkt_rcode ldns_pkt_get_rcode(const ldns_pkt *packet)
Return the packet's respons code.
bool ldns_pkt_set_flags(ldns_pkt *packet, uint16_t flags)
sets the flags in a packet.
ldns_status ldns_str2rdf_dname(ldns_rdf **d, const char *str)
convert a dname string into wireformat
bool ldns_pkt_ra(const ldns_pkt *packet)
Read the packet's ra bit.
ldns_pkt_opcode _opcode
Query type.
size_t _size
The size of the wire format of the packet in octets.
bool ldns_pkt_tc(const ldns_pkt *packet)
Read the packet's tc bit.
void ldns_rr_free(ldns_rr *rr)
frees an RR structure
void ldns_pkt_free(ldns_pkt *packet)
frees the packet structure and all data that it contains.
bool ldns_pkt_rd(const ldns_pkt *packet)
Read the packet's rd bit.
void ldns_pkt_set_edns_do(ldns_pkt *packet, bool value)
void ldns_pkt_set_size(ldns_pkt *packet, size_t s)
Set the packet's size.
uint8_t ldns_pkt_edns_version(const ldns_pkt *packet)
return the packet's edns version
void ldns_rdf_free(ldns_rdf *rd)
frees a rdf structure, leaving the data pointer intact.
uint8_t _edns_version
EDNS Version.
signed char _aa
Authoritative answer.
void ldns_pkt_set_additional(ldns_pkt *p, ldns_rr_list *rr)
directly set the additional section
void ldns_pkt_set_ad(ldns_pkt *packet, bool ad)
@ LDNS_RR_TYPE_NS
an authoritative name server
uint16_t _id
Id of a packet.
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.
ldns_rdf * ldns_pkt_answerfrom(const ldns_pkt *packet)
Return the packet's answerfrom.
ldns_rr_list * ldns_rr_list_clone(const ldns_rr_list *rrlist)
clones an rrlist.
enum ldns_enum_rr_type ldns_rr_type
@ LDNS_RR_TYPE_SOA
marks the start of a zone of authority
ldns_rr * ldns_rr_clone(const ldns_rr *rr)
clones a rr and all its data
bool ldns_pkt_ad(const ldns_pkt *packet)
Read the packet's ad bit.
bool 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
ldns_rr_list * ldns_pkt_authority(const ldns_pkt *packet)
Return the packet's authority section.
ldns_pkt * ldns_pkt_clone(const ldns_pkt *pkt)
clones the given packet, creating a fully allocated copy
void ldns_pkt_set_answerfrom(ldns_pkt *packet, ldns_rdf *answerfrom)
Set the packet's answering server.
void ldns_rdf_deep_free(ldns_rdf *rd)
frees a rdf structure and frees the data.
ldns_rdf * ldns_rdf_clone(const ldns_rdf *rd)
clones a rdf structure.
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.
#define LDNS_MALLOC(type)
Memory management macros.
struct timeval timestamp
Timestamp of the time the packet was sent or created.
uint8_t ldns_pkt_edns_extended_rcode(const ldns_pkt *packet)
return the packet's edns extended rcode
void ldns_pkt_set_rd(ldns_pkt *packet, bool rd)
uint16_t ldns_pkt_nscount(const ldns_pkt *packet)
Return the packet's ns count.
void ldns_rr_set_owner(ldns_rr *rr, ldns_rdf *owner)
sets the owner in the rr structure.
void ldns_pkt_set_authority(ldns_pkt *p, ldns_rr_list *rr)
directly set the auhority 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.
bool ldns_rr_list_contains_rr(const ldns_rr_list *rr_list, const ldns_rr *rr)
returns true if the given rr is one of the rrs in the list, or if it is equal to one
enum ldns_enum_pkt_type ldns_pkt_type
struct timeval ldns_pkt_timestamp(const ldns_pkt *packet)
Return the packet's timestamp.
void ldns_pkt_set_opcode(ldns_pkt *packet, ldns_pkt_opcode opcode)
Set the packet's opcode.
enum ldns_enum_status ldns_status
@ LDNS_SECTION_ANY_NOQUESTION
used to get all non-question rrs from a packet
A general purpose lookup table.
@ LDNS_SECTION_ANY
bogus section, if not interested
ldns_rr_list * ldns_rr_list_cat_clone(const ldns_rr_list *left, const ldns_rr_list *right)
concatenates two ldns_rr_lists together, but makes clones of the rr's (instead of pointer copying).
signed char _ad
Authentic data.
uint16_t _qdcount
question sec
Resource record data field.
enum ldns_enum_pkt_section ldns_pkt_section
void ldns_pkt_set_ancount(ldns_pkt *packet, uint16_t ancount)
Set the packet's an count.
ldns_status ldns_pkt_ixfr_request_new_frm_str(ldns_pkt **p, const char *name, ldns_rr_class rr_class, uint16_t flags, ldns_rr *soa)
creates an IXFR request packet for the given name, class.
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,...
ldns_rr_list * ldns_pkt_additional(const ldns_pkt *packet)
Return the packet's additional section.
ldns_pkt * ldns_pkt_new(void)
allocates and initializes a ldns_pkt structure.
ldns_rr_list * _additional
Additional section.
void ldns_pkt_set_arcount(ldns_pkt *packet, uint16_t arcount)
Set the packet's arcount.
bool ldns_pkt_cd(const ldns_pkt *packet)
Read the packet's cd bit.
void ldns_pkt_set_rcode(ldns_pkt *packet, uint8_t rcode)
Set the packet's respons code.
ldns_hdr * _header
Header section.
uint16_t _edns_udp_size
EDNS0 available buffer size, see RFC2671.
void ldns_pkt_set_answer(ldns_pkt *p, ldns_rr_list *rr)
directly set the answer section
bool ldns_rr_push_rdf(ldns_rr *rr, const ldns_rdf *f)
sets rd_field member, it will be placed in the next available spot.
bool ldns_pkt_push_rr_list(ldns_pkt *p, ldns_pkt_section s, ldns_rr_list *list)
push a rr_list on a packet
bool ldns_pkt_qr(const ldns_pkt *packet)
Read the packet's qr bit.
bool ldns_pkt_edns(const ldns_pkt *pkt)
returns true if this packet needs and EDNS rr to be sent.
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.
void ldns_pkt_set_aa(ldns_pkt *packet, bool aa)
void ldns_pkt_set_edns_data(ldns_pkt *packet, ldns_rdf *data)
Set the packet's edns data.
ldns_rr_list * ldns_rr_list_new(void)
creates a new rr_list structure.
uint16_t _edns_z
Reserved EDNS data bits.
void ldns_pkt_set_ra(ldns_pkt *packet, bool ra)
uint16_t ldns_get_random(void)
Get random number.
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.
bool ldns_pkt_empty(ldns_pkt *p)
check if a packet is empty
void ldns_pkt_set_qdcount(ldns_pkt *packet, uint16_t qdcount)
Set the packet's qd count.
@ LDNS_RR_TYPE_A
a host address
ldns_rr_list * ldns_pkt_answer(const ldns_pkt *packet)
Return the packet's answer section.
uint16_t ldns_pkt_ancount(const ldns_pkt *packet)
Return the packet's an count.
int ldns_dname_compare(const ldns_rdf *dname1, const ldns_rdf *dname2)
Compares the two dname rdf's according to the algorithm for ordering in RFC4034 Section 6.
uint16_t _nscount
auth sec
ldns_rr * ldns_pkt_tsig(const ldns_pkt *pkt)
Return the packet's tsig pseudo rr's.
ldns_rr * ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr)
returns a specific rr of an rrlist.
void ldns_rr_list_free(ldns_rr_list *rr_list)
frees an rr_list structure.
uint8_t _rcode
Response code.
signed char _qr
Query bit (0=query, 1=answer)
uint16_t ldns_pkt_edns_udp_size(const ldns_pkt *packet)
return the packet's edns udp size
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_random_id(ldns_pkt *packet)
Set the packet's id to a random value.
ldns_rr_list * _authority
Authority section.
uint8_t _edns_extended_rcode
EDNS0 Extended rcode.
enum ldns_enum_pkt_rcode ldns_pkt_rcode
ldns_rdf * ldns_rr_owner(const ldns_rr *rr)
returns the owner name of an rr structure.
void ldns_rr_set_type(ldns_rr *rr, ldns_rr_type rr_type)
sets the type in the rr.
void ldns_pkt_set_id(ldns_pkt *packet, uint16_t id)
Set the packet's id.
@ LDNS_SECTION_ADDITIONAL
ldns_rdf * _answerfrom
an rdf (A or AAAA) with the IP address of the server it is from
uint16_t ldns_pkt_arcount(const ldns_pkt *packet)
Return the packet's ar count.
void ldns_pkt_set_edns_udp_size(ldns_pkt *packet, uint16_t s)
Set the packet's edns udp size.
void ldns_pkt_set_question(ldns_pkt *p, ldns_rr_list *rr)
directly set the question section
size_t ldns_pkt_size(const ldns_pkt *packet)
Return the packet's size in bytes.
void ldns_pkt_set_tc(ldns_pkt *packet, bool tc)
ldns_rr_type ldns_rr_get_type(const ldns_rr *rr)
returns the type of the rr.
size_t ldns_rr_list_rr_count(const ldns_rr_list *rr_list)
returns the number of rr's in an rr_list.