 |
ldns
1.7.0
|
Go to the documentation of this file.
59 uint16_t pointer_target;
60 uint8_t pointer_target_buf[2];
62 size_t uncompressed_length = 0;
63 size_t compression_pos = 0;
65 unsigned int pointer_count = 0;
73 label_size = wire[*pos];
74 while (label_size > 0) {
76 while (label_size >= 192) {
77 if (compression_pos == 0) {
78 compression_pos = *pos + 2;
87 pointer_target_buf[0] = wire[*pos] & 63;
88 pointer_target_buf[1] = wire[*pos + 1];
89 pointer_target = ldns_read_uint16(pointer_target_buf);
91 if (pointer_target == 0) {
93 }
else if (pointer_target >= max) {
98 *pos = pointer_target;
99 label_size = wire[*pos];
106 if (*pos + 1 + label_size > max) {
114 tmp_dname[dname_pos] = label_size;
115 if (label_size > 0) {
122 memcpy(&tmp_dname[dname_pos], &wire[*pos], label_size);
123 uncompressed_length += label_size + 1;
124 dname_pos += label_size;
125 *pos = *pos + label_size;
128 label_size = wire[*pos];
132 if (compression_pos > 0) {
133 *pos = compression_pos;
142 tmp_dname[dname_pos] = 0;
146 (uint16_t) dname_pos, tmp_dname);
154 #define LDNS_STATUS_CHECK_RETURN(st) {if (st != LDNS_STATUS_OK) { return st; }}
155 #define LDNS_STATUS_CHECK_GOTO(st, label) {if (st != LDNS_STATUS_OK) { goto label; }}
161 size_t cur_rdf_length;
174 if (*pos + 2 > max) {
178 rd_length = ldns_read_uint16(&wire[*pos]);
181 if (*pos + rd_length > max) {
185 end = *pos + (size_t) rd_length;
194 descriptor, rdf_index);
198 switch (cur_rdf_type) {
240 cur_rdf_length = ((size_t) wire[*pos]) + 1;
244 if (*pos + 2 > end) {
248 (size_t) ldns_read_uint16(&wire[*pos]) + 2;
251 if (*pos + 4 > end) {
255 (size_t) wire[*pos] +
256 (
size_t) ldns_read_uint16(&wire[*pos + 2]) + 4;
261 cur_rdf_length = ((size_t) wire[*pos]) + 1;
279 cur_rdf_length = end - *pos;
284 if (cur_rdf_length > 0) {
285 if (cur_rdf_length + *pos > end) {
292 memcpy(data, &wire[*pos], cur_rdf_length);
295 cur_rdf_length, data);
296 *pos = *pos + cur_rdf_length;
331 if (*pos + 4 > max) {
343 if (*pos + 4 > max) {
367 ldns_wire2pkt_hdr(
ldns_pkt *packet,
const uint8_t *wire,
size_t max,
size_t *pos)
399 ldns_buffer_limit(buffer));
411 uint8_t have_edns = 0;
415 status = ldns_wire2pkt_hdr(packet, wire, max, &pos);
ldns_rdf * ldns_rr_rdf(const ldns_rr *rr, size_t nr)
returns the rdata field member counter.
#define LDNS_RDF_SIZE_WORD
#define LDNS_RDF_SIZE_BYTE
#define LDNS_AA_WIRE(wirebuf)
@ LDNS_STATUS_WIRE_INCOMPLETE_QUESTION
implementation of buffers to ease operations
@ LDNS_RDF_TYPE_MATCHING_TYPE
ldns_status ldns_wire2pkt(ldns_pkt **packet_p, const uint8_t *wire, size_t max)
converts the data on the uint8_t bytearray (in wire format) to a DNS packet.
@ LDNS_RDF_TYPE_HEX
hex string
void ldns_pkt_set_qr(ldns_pkt *packet, bool qr)
@ LDNS_RDF_TYPE_INT32
32 bits
#define LDNS_AD_WIRE(wirebuf)
#define LDNS_ID_WIRE(wirebuf)
@ LDNS_STATUS_WIRE_INCOMPLETE_AUTHORITY
#define LDNS_RDF_SIZE_DOUBLEWORD
ldns_status ldns_wire2rr(ldns_rr **rr_p, const uint8_t *wire, size_t max, size_t *pos, ldns_pkt_section section)
converts the data on the uint8_t bytearray (in wire format) to a DNS resource record.
#define LDNS_STATUS_CHECK_GOTO(st, label)
@ LDNS_RDF_TYPE_INT16
16 bits
ldns_rr_list * ldns_pkt_question(const ldns_pkt *packet)
Return the packet's question section.
#define LDNS_STATUS_CHECK_RETURN(st)
void ldns_pkt_set_edns_extended_rcode(ldns_pkt *packet, uint8_t c)
Set the packet's edns extended rcode.
void ldns_pkt_set_edns_z(ldns_pkt *packet, uint16_t z)
Set the packet's edns z value.
@ LDNS_RDF_TYPE_NSAP
NSAP.
#define LDNS_NSCOUNT(wirebuf)
@ LDNS_RDF_TYPE_LOC
location data
@ LDNS_RDF_TYPE_TAG
A non-zero sequence of US-ASCII letters and numbers in lower case.
bool ldns_rr_list_push_rr(ldns_rr_list *rr_list, const ldns_rr *rr)
pushes an rr to an rrlist.
ldns_status ldns_wire2rdf(ldns_rr *rr, const uint8_t *wire, size_t max, size_t *pos)
converts the data on the uint8_t bytearray (in wire format) to DNS rdata fields, and adds them to the...
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.
@ LDNS_RDF_TYPE_A
A record.
enum ldns_enum_rdf_type ldns_rdf_type
@ LDNS_STATUS_INVALID_POINTER
void ldns_pkt_set_cd(ldns_pkt *packet, bool cd)
@ LDNS_STATUS_INTERNAL_ERR
void ldns_rr_set_ttl(ldns_rr *rr, uint32_t ttl)
sets the ttl in the rr structure.
void ldns_rr_set_class(ldns_rr *rr, ldns_rr_class rr_class)
sets the class in the rr.
void ldns_rr_set_question(ldns_rr *rr, bool question)
#define LDNS_MAX_POINTERS
Maximum number of pointers in 1 dname.
void ldns_pkt_set_tsig(ldns_pkt *pkt, ldns_rr *rr)
Set the packet's tsig rr.
@ LDNS_RDF_TYPE_CERT_ALG
certificate algorithm
ldns_rr * ldns_rr_new(void)
creates a new rr structure.
#define LDNS_MAX_LABELLEN
Maximum length of a dname label.
@ LDNS_RDF_TYPE_APL
apl data
@ LDNS_RR_TYPE_OPT
Pseudo OPT record...
void ldns_pkt_set_nscount(ldns_pkt *packet, uint16_t nscount)
Set the packet's ns count.
@ LDNS_RDF_TYPE_CERTIFICATE_USAGE
Since RFC7218 TLSA records can be given with mnemonics, hence these rdata field types.
ldns_rdf_type ldns_rr_descriptor_field_type(const ldns_rr_descriptor *descriptor, size_t index)
returns the rdf type for the given rdata field number of the rr type for the given descriptor.
#define LDNS_TC_WIRE(wirebuf)
@ LDNS_STATUS_WIRE_RDATA_ERR
#define LDNS_QDCOUNT(wirebuf)
ldns_rr_class ldns_rr_get_class(const ldns_rr *rr)
returns the class of the rr.
@ LDNS_RDF_TYPE_SERVICE
protocol and port bitmaps
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.
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_data(ldns_rdf_type type, size_t size, const void *data)
allocates a new rdf structure and fills it.
void ldns_pkt_set_size(ldns_pkt *packet, size_t s)
Set the packet's size.
@ LDNS_STATUS_PACKET_OVERFLOW
@ LDNS_RDF_TYPE_ILNP64
4 shorts represented as 4 * 16 bit hex numbers separated by colons.
@ LDNS_STATUS_DOMAINNAME_OVERFLOW
void ldns_pkt_set_ad(ldns_pkt *packet, bool ad)
@ LDNS_RDF_TYPE_ATMA
ATMA.
ldns_status ldns_wire2dname(ldns_rdf **dname, const uint8_t *wire, size_t max, size_t *pos)
converts the data on the uint8_t bytearray (in wire format) to a DNS dname rdata field.
@ LDNS_STATUS_LABEL_OVERFLOW
ldns_rr_list * ldns_pkt_authority(const ldns_pkt *packet)
Return the packet's authority section.
ldns_rdf * ldns_rdf_clone(const ldns_rdf *rd)
clones a rdf structure.
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.
@ LDNS_RDF_TYPE_TSIGTIME
tsig time 48 bits
@ LDNS_RDF_TYPE_HIP
Represents the Public Key Algorithm, HIT and Public Key fields for the HIP RR types.
void ldns_rr_set_owner(ldns_rr *rr, ldns_rdf *owner)
sets the owner in the rr structure.
@ LDNS_STATUS_WIRE_INCOMPLETE_HEADER
@ LDNS_STATUS_WIRE_INCOMPLETE_ANSWER
void ldns_pkt_set_opcode(ldns_pkt *packet, ldns_pkt_opcode opcode)
Set the packet's opcode.
enum ldns_enum_status ldns_status
@ LDNS_RDF_TYPE_B64
b64 string
#define LDNS_XMALLOC(type, count)
@ LDNS_RDF_TYPE_LONG_STR
A <character-string> encoding of the value field as specified [RFC1035], Section 5....
@ LDNS_RDF_TYPE_DNAME
domain name
@ LDNS_RDF_TYPE_B32_EXT
b32 string
@ LDNS_RDF_TYPE_EUI64
8 * 8 bit hex numbers separated by dashes.
#define LDNS_CD_WIRE(wirebuf)
@ LDNS_RDF_TYPE_EUI48
6 * 8 bit hex numbers separated by dashes.
@ LDNS_RDF_TYPE_NSEC3_NEXT_OWNER
nsec3 base32 string (with length byte on wire
#define LDNS_ARCOUNT(wirebuf)
@ LDNS_STATUS_WIRE_INCOMPLETE_ADDITIONAL
@ LDNS_RDF_TYPE_WKS
well known services
Resource record data field.
enum ldns_enum_pkt_section ldns_pkt_section
#define LDNS_RD_WIRE(wirebuf)
void ldns_pkt_set_ancount(ldns_pkt *packet, uint16_t ancount)
Set the packet's an count.
ldns_rr_list * ldns_pkt_additional(const ldns_pkt *packet)
Return the packet's additional section.
Contains all information about resource record types.
#define LDNS_RDF_SIZE_16BYTES
uint32_t ldns_rr_ttl(const ldns_rr *rr)
returns the ttl of an rr structure.
@ LDNS_RDF_TYPE_INT8
8 bits
ldns_pkt * ldns_pkt_new(void)
allocates and initializes a ldns_pkt structure.
void ldns_pkt_set_arcount(ldns_pkt *packet, uint16_t arcount)
Set the packet's arcount.
@ LDNS_RDF_TYPE_UNKNOWN
unknown types
#define LDNS_RCODE_WIRE(wirebuf)
void ldns_pkt_set_rcode(ldns_pkt *packet, uint8_t rcode)
Set the packet's respons code.
#define LDNS_OPCODE_WIRE(wirebuf)
@ LDNS_RDF_TYPE_PERIOD
period
@ LDNS_RDF_TYPE_INT16_DATA
variable length any type rdata where the length is specified by the first 2 bytes
@ LDNS_RDF_TYPE_STR
txt string
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.
size_t ldns_rr_descriptor_maximum(const ldns_rr_descriptor *descriptor)
returns the maximum number of rdata fields of the rr type this descriptor describes.
@ LDNS_RDF_TYPE_IPSECKEY
IPSECKEY.
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_RDF_TYPE_CLASS
a class
void ldns_pkt_set_ra(ldns_pkt *packet, bool ra)
@ LDNS_RDF_TYPE_NSEC
nsec type codes
#define LDNS_QR_WIRE(wirebuf)
void ldns_pkt_set_qdcount(ldns_pkt *packet, uint16_t qdcount)
Set the packet's qd count.
#define LDNS_RDF_SIZE_6BYTES
ldns_status ldns_buffer2pkt_wire(ldns_pkt **packet, const ldns_buffer *buffer)
converts the data in the ldns_buffer (in wire format) to a DNS packet.
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.
@ LDNS_RDF_TYPE_AAAA
AAAA record.
@ LDNS_RDF_TYPE_NSEC3_SALT
nsec3 hash salt
@ LDNS_RDF_TYPE_TYPE
a RR type
const ldns_rr_descriptor * ldns_rr_descript(uint16_t type)
returns the resource record descriptor for the given rr type.
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_RDF_TYPE_TIME
time (32 bits)
#define LDNS_MAX_DOMAINLEN
Maximum length of a complete dname.
#define LDNS_RA_WIRE(wirebuf)
@ LDNS_SECTION_ADDITIONAL
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_tc(ldns_pkt *packet, bool tc)
@ LDNS_RDF_TYPE_ALG
a key algorithm
#define LDNS_RDF_SIZE_8BYTES
#define LDNS_ANCOUNT(wirebuf)
ldns_rr_type ldns_rr_get_type(const ldns_rr *rr)
returns the type of the rr.