42 return ldns_buffer_status(buffer);
50 ldns_buffer_write_u8(buffer, 0);
52 return ldns_buffer_status(buffer);
59 uint16_t position = (uint16_t) (intptr_t) node->
data | 0xC000;
62 ldns_buffer_write_u16(buffer, position);
64 return ldns_buffer_status(buffer);
70 if (ldns_buffer_position(buffer) < 16384) {
85 node->
data = (
void *) (intptr_t) ldns_buffer_position(buffer);
99 ldns_buffer_write(buffer, data, size);
126 return ldns_buffer_status(buffer);
139 ldns_buffer_write_u8(buffer,
146 ldns_buffer_write(buffer,
151 return ldns_buffer_status(buffer);
162 for(i = 0; i < rr_count; i++) {
166 return ldns_buffer_status(buffer);
176 uint16_t rdl_pos = 0;
177 bool pre_rfc3597 =
false;
222 rdl_pos = ldns_buffer_position(buffer);
223 ldns_buffer_write_u16(buffer, 0);
235 ldns_buffer_write_u16_at(buffer, rdl_pos,
236 ldns_buffer_position(buffer)
240 return ldns_buffer_status(buffer);
253 uint16_t rdl_pos = 0;
268 rdl_pos = ldns_buffer_position(buffer);
269 ldns_buffer_write_u16(buffer, 0);
285 ldns_buffer_write_u16_at(buffer, rdl_pos,
286 ldns_buffer_position(buffer)
290 return ldns_buffer_status(buffer);
310 return ldns_buffer_status(buffer);
322 return ldns_buffer_status(buffer);
335 ldns_buffer_write_u16(buffer,
ldns_pkt_id(packet));
341 ldns_buffer_write_u8(buffer, flags);
348 ldns_buffer_write_u8(buffer, flags);
361 ldns_buffer_write_u16(buffer, arcount);
364 return ldns_buffer_status(buffer);
402 (void) ldns_hdr2buffer_wire(buffer, packet);
448 , ldns_buffer_limit(edns_buf)
486 *result_size = ldns_buffer_position(buffer);
504 *result_size = ldns_buffer_position(buffer);
522 *result_size = ldns_buffer_position(buffer);
void ldns_buffer_free(ldns_buffer *buffer)
frees the buffer.
bool ldns_buffer_reserve(ldns_buffer *buffer, size_t amount)
ensures BUFFER can contain at least AMOUNT more bytes.
ldns_buffer * ldns_buffer_new(size_t capacity)
creates a new buffer with the specified capacity.
void * ldns_buffer_export(ldns_buffer *buffer)
Makes the buffer fixed and returns a pointer to the data.
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.
ldns_rdf * ldns_dname_left_chop(const ldns_rdf *d)
chop one label off the left side of a dname.
uint8_t ldns_dname_label_count(const ldns_rdf *r)
count the number of labels inside a LDNS_RDF_DNAME type rdf.
ldns_rdf * ldns_dname_label(const ldns_rdf *rdf, uint8_t labelpos)
look inside the rdf and if it is an LDNS_RDF_TYPE_DNAME try and retrieve a specific label.
#define LDNS_DNAME_NORMALIZE
ldns_buffer * ldns_edns_option_list2wireformat_buffer(const ldns_edns_option_list *option_list)
serializes all the EDNS options into a single wireformat buffer
enum ldns_enum_status ldns_status
ldns_status ldns_rdf2buffer_wire(ldns_buffer *buffer, const ldns_rdf *rdf)
Copies the rdata data to the buffer in wire format.
ldns_status ldns_rr2buffer_wire_canonical(ldns_buffer *buffer, const ldns_rr *rr, int section)
Copies the rr data to the buffer in wire format, in canonical format according to RFC3597 (every dnam...
ldns_status ldns_rr_list2buffer_wire(ldns_buffer *buffer, const ldns_rr_list *rr_list)
Copies the rr_list data to the buffer in wire format.
ldns_status ldns_rrsig2buffer_wire(ldns_buffer *buffer, const ldns_rr *rr)
Converts a rrsig to wireformat BUT EXCLUDE the rrsig rdata This is needed in DNSSEC verification.
ldns_status ldns_pkt2wire(uint8_t **dest, const ldns_pkt *packet, size_t *result_size)
Allocates an array of uint8_t at dest, and puts the wireformat of the given packet in that array.
ldns_status ldns_rdf2buffer_wire_canonical(ldns_buffer *buffer, const ldns_rdf *rdf)
Copies the rdata data to the buffer in wire format If the rdata is a dname, the letters will be lower...
ldns_status ldns_rdf2buffer_wire_compress(ldns_buffer *buffer, const ldns_rdf *rdf, ldns_rbtree_t *compression_data)
Copies the rdata data to the buffer in wire format.
ldns_status ldns_dname2buffer_wire_compress(ldns_buffer *buffer, const ldns_rdf *name, ldns_rbtree_t *compression_data)
Copies the dname data to the buffer in wire format.
ldns_status ldns_rdf2wire(uint8_t **dest, const ldns_rdf *rdf, size_t *result_size)
Allocates an array of uint8_t at dest, and puts the wireformat of the given rdf in that array.
ldns_status ldns_pkt2buffer_wire(ldns_buffer *buffer, const ldns_pkt *packet)
Copies the packet data to the buffer in wire format.
ldns_status ldns_dname2buffer_wire(ldns_buffer *buffer, const ldns_rdf *name)
Copies the dname data to the buffer in wire format.
ldns_status ldns_rr2wire(uint8_t **dest, const ldns_rr *rr, int section, size_t *result_size)
Allocates an array of uint8_t at dest, and puts the wireformat of the given rr in that array.
ldns_status ldns_rr2buffer_wire_compress(ldns_buffer *buffer, const ldns_rr *rr, int section, ldns_rbtree_t *compression_data)
Copies the rr data to the buffer in wire format while doing DNAME compression.
ldns_status ldns_rr_rdata2buffer_wire(ldns_buffer *buffer, const ldns_rr *rr)
Converts an rr's rdata to wireformat, while excluding the ownername and all the stuff before the rdat...
ldns_status ldns_rr2buffer_wire(ldns_buffer *buffer, const ldns_rr *rr, int section)
Copies the rr data to the buffer in wire format.
ldns_status ldns_pkt2buffer_wire_compress(ldns_buffer *buffer, const ldns_pkt *packet, ldns_rbtree_t *compression_data)
Copies the packet data to the buffer in wire format.
Including this file will include all ldns files, and define some lookup tables.
uint8_t ldns_pkt_edns_version(const ldns_pkt *packet)
return the packet's edns version
ldns_pkt_opcode ldns_pkt_get_opcode(const ldns_pkt *packet)
Read the packet's code.
ldns_rr_list * ldns_pkt_question(const ldns_pkt *packet)
Return the packet's question section.
uint16_t ldns_pkt_id(const ldns_pkt *packet)
Read the packet id.
uint16_t ldns_pkt_arcount(const ldns_pkt *packet)
Return the packet's ar count.
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_rr_list * ldns_pkt_authority(const ldns_pkt *packet)
Return the packet's authority section.
uint16_t ldns_pkt_ancount(const ldns_pkt *packet)
Return the packet's an count.
bool ldns_pkt_cd(const ldns_pkt *packet)
Read the packet's cd bit.
ldns_rr_list * ldns_pkt_additional(const ldns_pkt *packet)
Return the packet's additional section.
bool ldns_pkt_ad(const ldns_pkt *packet)
Read the packet's ad bit.
bool ldns_pkt_rd(const ldns_pkt *packet)
Read the packet's rd bit.
uint8_t ldns_pkt_edns_extended_rcode(const ldns_pkt *packet)
return the packet's edns extended rcode
bool ldns_pkt_ra(const ldns_pkt *packet)
Read the packet's ra bit.
ldns_rr_list * ldns_pkt_answer(const ldns_pkt *packet)
Return the packet's answer section.
uint16_t ldns_pkt_nscount(const ldns_pkt *packet)
Return the packet's ns count.
uint16_t ldns_pkt_qdcount(const ldns_pkt *packet)
Return the packet's qd count.
ldns_rr * ldns_pkt_tsig(const ldns_pkt *pkt)
Return the packet's tsig pseudo rr's.
uint16_t ldns_pkt_edns_z(const ldns_pkt *packet)
return the packet's edns z value
bool ldns_pkt_aa(const ldns_pkt *packet)
Read the packet's aa bit.
ldns_pkt_rcode ldns_pkt_get_rcode(const ldns_pkt *packet)
Return the packet's response code.
bool ldns_pkt_tc(const ldns_pkt *packet)
Read the packet's tc bit.
uint16_t ldns_pkt_edns_udp_size(const ldns_pkt *packet)
return the packet's edns udp size
#define LDNS_MAX_PACKETLEN
@ LDNS_SECTION_ANY
bogus section, if not interested
@ LDNS_SECTION_ADDITIONAL
ldns_rbtree_t * ldns_rbtree_create(int(*cmpf)(const void *, const void *))
Create new tree (malloced) with given key compare function.
void ldns_traverse_postorder(ldns_rbtree_t *tree, void(*func)(ldns_rbnode_t *, void *), void *arg)
Call function for all elements in the redblack tree, such that leaf elements are called before parent...
void ldns_rbtree_free(ldns_rbtree_t *rbtree)
Free the complete tree (but not its keys)
ldns_rbnode_t * ldns_rbtree_search(ldns_rbtree_t *rbtree, const void *key)
Find key in tree.
ldns_rbnode_t * ldns_rbtree_insert(ldns_rbtree_t *rbtree, ldns_rbnode_t *data)
Insert data into the tree.
ldns_rdf_type ldns_rdf_get_type(const ldns_rdf *rd)
returns the type of the rdf.
void ldns_rdf_deep_free(ldns_rdf *rd)
frees a rdf structure and frees the data.
ldns_rdf * ldns_rdf_new(ldns_rdf_type type, size_t size, void *data)
allocates a new rdf structure and fills it.
ldns_rdf * ldns_rdf_new_frm_str(ldns_rdf_type type, const char *str)
creates a new rdf from a string.
size_t ldns_rdf_size(const ldns_rdf *rd)
returns the size of the rdf.
uint8_t * ldns_rdf_data(const ldns_rdf *rd)
returns the data of the rdf.
ldns_rdf * ldns_rdf_clone(const ldns_rdf *rd)
clones a rdf structure.
@ LDNS_RDF_TYPE_UNKNOWN
unknown types
@ LDNS_RDF_TYPE_DNAME
domain name
ldns_rr * ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr)
returns a specific rr of an rrlist.
uint32_t ldns_rr_ttl(const ldns_rr *rr)
returns the ttl of an rr structure.
ldns_rdf * ldns_rr_owner(const ldns_rr *rr)
returns the owner name of an rr structure.
const ldns_rr_descriptor * ldns_rr_descript(uint16_t type)
returns the resource record descriptor for the given rr type.
void ldns_rr_free(ldns_rr *rr)
frees an RR structure
void ldns_rr_set_owner(ldns_rr *rr, ldns_rdf *owner)
sets the owner in the rr structure.
void ldns_rr_set_type(ldns_rr *rr, ldns_rr_type rr_type)
sets the type in the rr.
size_t ldns_rr_rd_count(const ldns_rr *rr)
returns the rd_count of an rr structure.
size_t ldns_rr_list_rr_count(const ldns_rr_list *rr_list)
returns the number of rr's in an rr_list.
ldns_rr_type ldns_rr_get_type(const ldns_rr *rr)
returns the type of the rr.
void ldns_rr_set_ttl(ldns_rr *rr, uint32_t ttl)
sets the ttl in the rr structure.
ldns_rr_class ldns_rr_get_class(const ldns_rr *rr)
returns the class of the rr.
void ldns_rr_set_class(ldns_rr *rr, ldns_rr_class rr_class)
sets the class in the rr.
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.
ldns_rdf * ldns_rr_rdf(const ldns_rr *rr, size_t nr)
returns the rdata field member counter.
ldns_rr * ldns_rr_new(void)
creates a new rr structure.
ldns_rdf * ldns_rr_pop_rdf(ldns_rr *rr)
removes a rd_field member, it will be popped from the last position.
@ LDNS_RR_COMPRESS
compression is allowed
@ LDNS_RR_TYPE_MF
a mail forwarder (Obsolete - use MX)
@ LDNS_RR_TYPE_RP
RFC1183.
@ LDNS_RR_TYPE_KX
RFC2230.
@ LDNS_RR_TYPE_OPT
OPT record RFC 6891.
@ LDNS_RR_TYPE_RRSIG
DNSSEC.
@ LDNS_RR_TYPE_MINFO
mailbox or mail list information
@ LDNS_RR_TYPE_SOA
marks the start of a zone of authority
@ LDNS_RR_TYPE_PX
RFC2163.
@ LDNS_RR_TYPE_RT
RFC1183.
@ LDNS_RR_TYPE_DNAME
RFC2672.
@ LDNS_RR_TYPE_NXT
2535typecode
@ LDNS_RR_TYPE_SIG
2535typecode
@ LDNS_RR_TYPE_CNAME
the canonical name for an alias
@ LDNS_RR_TYPE_PTR
a domain name pointer
@ LDNS_RR_TYPE_MD
a mail destination (Obsolete - use MX)
@ LDNS_RR_TYPE_A6
RFC2874.
@ LDNS_RR_TYPE_NS
an authoritative name server
@ LDNS_RR_TYPE_MR
a mail rename domain name (EXPERIMENTAL)
@ LDNS_RR_TYPE_MB
a mailbox domain name (EXPERIMENTAL)
@ LDNS_RR_TYPE_HINFO
host information
@ LDNS_RR_TYPE_AFSDB
RFC1183.
@ LDNS_RR_TYPE_NAPTR
RFC2915.
@ LDNS_RR_TYPE_SRV
SRV record RFC2782.
@ LDNS_RR_TYPE_MX
mail exchange
@ LDNS_RR_TYPE_MG
a mail group member (EXPERIMENTAL)
The rbnode_t struct definition.
const void * data
pointer to data
const void * key
pointer to sorting key
definition for tree struct
implementation of buffers to ease operations
ldns_rdf * _edns_data
Arbitrary EDNS rdata.
ldns_edns_option_list * _edns_list
Structed EDNS data.
Resource record data field.
List or Set of Resource Records.
#define LDNS_MALLOC(type)
Memory management macros.