Go to the source code of this file.
Data Structures | |
struct | ldns_struct_hdr |
Header of a dns packet. More... | |
struct | ldns_struct_pkt |
DNS packet. More... | |
Defines | |
#define | LDNS_MAX_PACKETLEN 65535 |
#define | LDNS_QR 1 |
#define | LDNS_AA 2 |
#define | LDNS_TC 4 |
#define | LDNS_RD 8 |
#define | LDNS_CD 16 |
#define | LDNS_RA 32 |
#define | LDNS_AD 64 |
Typedefs | |
typedef enum ldns_enum_pkt_opcode | ldns_pkt_opcode |
typedef enum ldns_enum_pkt_rcode | ldns_pkt_rcode |
typedef struct ldns_struct_hdr | ldns_hdr |
typedef struct ldns_struct_pkt | ldns_pkt |
typedef enum ldns_enum_pkt_section | ldns_pkt_section |
typedef enum ldns_enum_pkt_type | ldns_pkt_type |
Enumerations | |
enum | ldns_enum_pkt_opcode { LDNS_PACKET_QUERY = 0, LDNS_PACKET_IQUERY = 1, LDNS_PACKET_STATUS = 2, LDNS_PACKET_NOTIFY = 4, LDNS_PACKET_UPDATE = 5 } |
enum | ldns_enum_pkt_rcode { LDNS_RCODE_NOERROR = 0, LDNS_RCODE_FORMERR = 1, LDNS_RCODE_SERVFAIL = 2, LDNS_RCODE_NXDOMAIN = 3, LDNS_RCODE_NOTIMPL = 4, LDNS_RCODE_REFUSED = 5, LDNS_RCODE_YXDOMAIN = 6, LDNS_RCODE_YXRRSET = 7, LDNS_RCODE_NXRRSET = 8, LDNS_RCODE_NOTAUTH = 9, LDNS_RCODE_NOTZONE = 10 } |
enum | ldns_enum_pkt_section { LDNS_SECTION_QUESTION = 0, LDNS_SECTION_ANSWER = 1, LDNS_SECTION_AUTHORITY = 2, LDNS_SECTION_ADDITIONAL = 3, LDNS_SECTION_ANY = 4, LDNS_SECTION_ANY_NOQUESTION = 5 } |
The sections of a packet. More... | |
enum | ldns_enum_pkt_type { LDNS_PACKET_QUESTION, LDNS_PACKET_REFERRAL, LDNS_PACKET_ANSWER, LDNS_PACKET_NXDOMAIN, LDNS_PACKET_NODATA, LDNS_PACKET_UNKNOWN } |
The different types of packets. More... | |
Functions | |
uint16_t | ldns_pkt_id (const ldns_pkt *p) |
Read the packet id. | |
bool | ldns_pkt_qr (const ldns_pkt *p) |
Read the packet's qr bit. | |
bool | ldns_pkt_aa (const ldns_pkt *p) |
Read the packet's aa bit. | |
bool | ldns_pkt_tc (const ldns_pkt *p) |
Read the packet's tc bit. | |
bool | ldns_pkt_rd (const ldns_pkt *p) |
Read the packet's rd bit. | |
bool | ldns_pkt_cd (const ldns_pkt *p) |
Read the packet's cd bit. | |
bool | ldns_pkt_ra (const ldns_pkt *p) |
Read the packet's ra bit. | |
bool | ldns_pkt_ad (const ldns_pkt *p) |
Read the packet's ad bit. | |
ldns_pkt_opcode | ldns_pkt_get_opcode (const ldns_pkt *p) |
Read the packet's code. | |
ldns_pkt_rcode | ldns_pkt_get_rcode (const ldns_pkt *p) |
Return the packet's respons code. | |
uint16_t | ldns_pkt_qdcount (const ldns_pkt *p) |
Return the packet's qd count. | |
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. | |
uint16_t | ldns_pkt_arcount (const ldns_pkt *p) |
Return the packet's ar count. | |
ldns_rdf * | ldns_pkt_answerfrom (const ldns_pkt *p) |
Return the packet's answerfrom. | |
struct timeval | ldns_pkt_timestamp (const ldns_pkt *p) |
Return the packet's timestamp. | |
uint32_t | ldns_pkt_querytime (const ldns_pkt *p) |
Return the packet's querytime. | |
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. | |
ldns_rr_list * | ldns_pkt_question (const ldns_pkt *p) |
Return the packet's question section. | |
ldns_rr_list * | ldns_pkt_answer (const ldns_pkt *p) |
Return the packet's answer section. | |
ldns_rr_list * | ldns_pkt_authority (const ldns_pkt *p) |
Return the packet's authority section. | |
ldns_rr_list * | ldns_pkt_additional (const ldns_pkt *p) |
Return the packet's additional section. | |
ldns_rr_list * | ldns_pkt_get_section_clone (ldns_pkt *p, ldns_pkt_section s) |
return all the rr_list's in the packet. | |
ldns_rr_list * | ldns_pkt_rr_list_by_name (ldns_pkt *p, ldns_rdf *r, ldns_pkt_section s) |
return all the rr with a specific name from a packet. | |
ldns_rr_list * | ldns_pkt_rr_list_by_type (ldns_pkt *p, ldns_rr_type t, ldns_pkt_section s) |
return all the rr with a specific type from a packet. | |
ldns_rr_list * | ldns_pkt_rr_list_by_name_and_type (ldns_pkt *packet, 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_rr (ldns_pkt *pkt, ldns_pkt_section sec, ldns_rr *rr) |
check to see if an rr exist in the packet | |
bool | ldns_pkt_set_flags (ldns_pkt *pkt, uint16_t flags) |
sets the flags in a packet. | |
void | ldns_pkt_set_id (ldns_pkt *p, uint16_t id) |
Set the packet's id. | |
void | ldns_pkt_set_random_id (ldns_pkt *p) |
Set the packet's id to a random value. | |
void | ldns_pkt_set_qr (ldns_pkt *p, bool b) |
Set the packet's qr bit. | |
void | ldns_pkt_set_aa (ldns_pkt *p, bool b) |
Set the packet's aa bit. | |
void | ldns_pkt_set_tc (ldns_pkt *p, bool b) |
Set the packet's tc bit. | |
void | ldns_pkt_set_rd (ldns_pkt *p, bool b) |
Set the packet's rd bit. | |
void | ldns_pkt_set_cd (ldns_pkt *p, bool b) |
Set the packet's cd bit. | |
void | ldns_pkt_set_ra (ldns_pkt *p, bool b) |
Set the packet's ra bit. | |
void | ldns_pkt_set_ad (ldns_pkt *p, bool b) |
Set the packet's ad bit. | |
void | ldns_pkt_set_opcode (ldns_pkt *p, ldns_pkt_opcode c) |
Set the packet's opcode. | |
void | ldns_pkt_set_rcode (ldns_pkt *p, uint8_t c) |
Set the packet's respons code. | |
void | ldns_pkt_set_qdcount (ldns_pkt *p, uint16_t c) |
Set the packet's qd count. | |
void | ldns_pkt_set_ancount (ldns_pkt *p, uint16_t c) |
Set the packet's an count. | |
void | ldns_pkt_set_nscount (ldns_pkt *p, uint16_t c) |
Set the packet's ns count. | |
void | ldns_pkt_set_arcount (ldns_pkt *p, uint16_t c) |
Set the packet's arcount. | |
void | ldns_pkt_set_answerfrom (ldns_pkt *p, ldns_rdf *r) |
Set the packet's answering server. | |
void | ldns_pkt_set_querytime (ldns_pkt *p, uint32_t t) |
Set the packet's query time. | |
void | ldns_pkt_set_size (ldns_pkt *p, size_t s) |
Set the packet's size. | |
void | ldns_pkt_set_timestamp (ldns_pkt *p, struct timeval) |
Set the packet's timestamp. | |
void | ldns_pkt_set_section_count (ldns_pkt *p, ldns_pkt_section s, uint16_t x) |
Set a packet's section count to x. | |
void | ldns_pkt_set_tsig (ldns_pkt *p, ldns_rr *t) |
Set the packet's tsig rr. | |
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. | |
uint16_t | ldns_pkt_edns_udp_size (const ldns_pkt *packet) |
return the packet's edns udp size | |
uint8_t | ldns_pkt_edns_extended_rcode (const ldns_pkt *packet) |
return the packet's edns extended rcode | |
uint8_t | ldns_pkt_edns_version (const ldns_pkt *packet) |
return the packet's edns version | |
uint16_t | ldns_pkt_edns_z (const ldns_pkt *packet) |
return the packet's edns z value | |
ldns_rdf * | ldns_pkt_edns_data (const ldns_pkt *packet) |
return the packet's edns data | |
bool | ldns_pkt_edns_do (const ldns_pkt *packet) |
return the packet's edns do bit | |
void | ldns_pkt_set_edns_do (ldns_pkt *packet, bool value) |
Set the packet's edns do bit. | |
bool | ldns_pkt_edns (const ldns_pkt *packet) |
returns true if this packet needs and EDNS rr to be sent. | |
void | ldns_pkt_set_edns_udp_size (ldns_pkt *packet, uint16_t s) |
Set the packet's edns udp size. | |
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_version (ldns_pkt *packet, uint8_t v) |
Set the packet's edns version. | |
void | ldns_pkt_set_edns_z (ldns_pkt *packet, uint16_t z) |
Set the packet's edns z value. | |
void | ldns_pkt_set_edns_data (ldns_pkt *packet, ldns_rdf *data) |
Set the packet's edns data. | |
ldns_pkt * | ldns_pkt_new () |
allocates and initializes a ldns_pkt structure. | |
void | ldns_pkt_free (ldns_pkt *packet) |
frees the packet structure and all data that it contains. | |
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. | |
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_pkt * | ldns_pkt_clone (ldns_pkt *pkt) |
clones the given packet, creating a fully allocated copy | |
void | ldns_pkt_set_additional (ldns_pkt *p, ldns_rr_list *rr) |
directly set the additional section | |
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_authority (ldns_pkt *p, ldns_rr_list *rr) |
directly set the auhority section | |
bool | ldns_pkt_push_rr (ldns_pkt *packet, ldns_pkt_section section, ldns_rr *rr) |
push an rr on a packet | |
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. | |
bool | ldns_pkt_push_rr_list (ldns_pkt *packet, ldns_pkt_section section, ldns_rr_list *list) |
push a rr_list on a packet | |
bool | 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. | |
bool | ldns_pkt_empty (ldns_pkt *p) |
check if a packet is empty |
Definition in file packet.h.
typedef enum ldns_enum_pkt_opcode ldns_pkt_opcode |
typedef enum ldns_enum_pkt_rcode ldns_pkt_rcode |
typedef struct ldns_struct_hdr ldns_hdr |
typedef struct ldns_struct_pkt ldns_pkt |
typedef enum ldns_enum_pkt_section ldns_pkt_section |
typedef enum ldns_enum_pkt_type ldns_pkt_type |
enum ldns_enum_pkt_opcode |
enum ldns_enum_pkt_rcode |
enum ldns_enum_pkt_type |
uint16_t ldns_pkt_id | ( | const ldns_pkt * | p | ) |
Read the packet id.
[in] | p | the packet |
Definition at line 39 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_id.
Read the packet's qr bit.
[in] | p | the packet |
Definition at line 45 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_qr.
Read the packet's aa bit.
[in] | p | the packet |
Definition at line 51 of file packet.c.
References ldns_struct_hdr::_aa, and ldns_struct_pkt::_header.
Read the packet's tc bit.
[in] | p | the packet |
Definition at line 57 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_tc.
Read the packet's rd bit.
[in] | p | the packet |
Definition at line 63 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_rd.
Read the packet's cd bit.
[in] | p | the packet |
Definition at line 69 of file packet.c.
References ldns_struct_hdr::_cd, and ldns_struct_pkt::_header.
Read the packet's ra bit.
[in] | p | the packet |
Definition at line 75 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_ra.
Read the packet's ad bit.
[in] | p | the packet |
Definition at line 81 of file packet.c.
References ldns_struct_hdr::_ad, and ldns_struct_pkt::_header.
ldns_pkt_opcode ldns_pkt_get_opcode | ( | const ldns_pkt * | p | ) |
Read the packet's code.
[in] | p | the packet |
Definition at line 87 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_opcode.
ldns_pkt_rcode ldns_pkt_get_rcode | ( | const ldns_pkt * | p | ) |
Return the packet's respons code.
[in] | p | the packet |
Definition at line 93 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_rcode.
uint16_t ldns_pkt_qdcount | ( | const ldns_pkt * | p | ) |
Return the packet's qd count.
[in] | p | the packet |
Definition at line 99 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_qdcount.
uint16_t ldns_pkt_ancount | ( | const ldns_pkt * | p | ) |
Return the packet's an count.
[in] | p | the packet |
Definition at line 105 of file packet.c.
References ldns_struct_hdr::_ancount, and ldns_struct_pkt::_header.
uint16_t ldns_pkt_nscount | ( | const ldns_pkt * | p | ) |
Return the packet's ns count.
[in] | p | the packet |
Definition at line 111 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_nscount.
uint16_t ldns_pkt_arcount | ( | const ldns_pkt * | p | ) |
Return the packet's ar count.
[in] | p | the packet |
Definition at line 117 of file packet.c.
References ldns_struct_hdr::_arcount, and ldns_struct_pkt::_header.
Return the packet's answerfrom.
[in] | p | packet |
Definition at line 194 of file packet.c.
References ldns_struct_pkt::_answerfrom.
struct timeval ldns_pkt_timestamp | ( | const ldns_pkt * | p | ) | [read] |
uint32_t ldns_pkt_querytime | ( | const ldns_pkt * | p | ) |
Return the packet's querytime.
[in] | p | the packet |
Definition at line 188 of file packet.c.
References ldns_struct_pkt::_querytime.
size_t ldns_pkt_size | ( | const ldns_pkt * | p | ) |
Return the packet's size in bytes.
[in] | p | the packet |
Definition at line 182 of file packet.c.
References ldns_struct_pkt::_size.
Return the packet's tsig pseudo rr's.
[in] | p | the packet |
Definition at line 433 of file packet.c.
References ldns_struct_pkt::_tsig_rr.
ldns_rr_list* ldns_pkt_question | ( | const ldns_pkt * | p | ) |
Return the packet's question section.
[in] | p | the packet |
Definition at line 123 of file packet.c.
References ldns_struct_pkt::_question.
ldns_rr_list* ldns_pkt_answer | ( | const ldns_pkt * | p | ) |
Return the packet's answer section.
[in] | p | the packet |
Definition at line 129 of file packet.c.
References ldns_struct_pkt::_answer.
ldns_rr_list* ldns_pkt_authority | ( | const ldns_pkt * | p | ) |
Return the packet's authority section.
[in] | p | the packet |
Definition at line 135 of file packet.c.
References ldns_struct_pkt::_authority.
ldns_rr_list* ldns_pkt_additional | ( | const ldns_pkt * | p | ) |
Return the packet's additional section.
[in] | p | the packet |
Definition at line 141 of file packet.c.
References ldns_struct_pkt::_additional.
ldns_rr_list* ldns_pkt_get_section_clone | ( | ldns_pkt * | p, | |
ldns_pkt_section | s | |||
) |
return all the rr_list's in the packet.
Clone the lists, instead of returning pointers.
[in] | p | the packet to look in |
[in] | s | what section(s) to return |
Definition at line 412 of file packet.c.
References ldns_pkt_additional(), ldns_pkt_all(), ldns_pkt_all_noquestion(), ldns_pkt_answer(), ldns_pkt_authority(), ldns_pkt_question(), ldns_rr_list_clone(), LDNS_SECTION_ADDITIONAL, LDNS_SECTION_ANSWER, LDNS_SECTION_ANY, LDNS_SECTION_ANY_NOQUESTION, LDNS_SECTION_AUTHORITY, and LDNS_SECTION_QUESTION.
ldns_rr_list* ldns_pkt_rr_list_by_name | ( | ldns_pkt * | p, | |
ldns_rdf * | r, | |||
ldns_pkt_section | s | |||
) |
return all the rr with a specific name from a packet.
Optionally specify from which section in the packet
[in] | p | the packet |
[in] | r | the name |
[in] | s | the packet's section |
Definition at line 253 of file packet.c.
References ldns_pkt_get_section_clone(), ldns_rdf_compare(), ldns_rr_list_new(), ldns_rr_list_push_rr(), ldns_rr_list_rr(), ldns_rr_list_rr_count(), and ldns_rr_owner().
ldns_rr_list* ldns_pkt_rr_list_by_type | ( | ldns_pkt * | p, | |
ldns_rr_type | t, | |||
ldns_pkt_section | s | |||
) |
return all the rr with a specific type from a packet.
Optionally specify from which section in the packet
[in] | p | the packet |
[in] | t | the type |
[in] | s | the packet's section |
Definition at line 282 of file packet.c.
References ldns_pkt_get_section_clone(), ldns_rr_clone(), ldns_rr_get_type(), ldns_rr_list_deep_free(), ldns_rr_list_free(), ldns_rr_list_new(), ldns_rr_list_push_rr(), ldns_rr_list_rr(), and ldns_rr_list_rr_count().
ldns_rr_list* ldns_pkt_rr_list_by_name_and_type | ( | ldns_pkt * | packet, | |
ldns_rdf * | ownername, | |||
ldns_rr_type | type, | |||
ldns_pkt_section | sec | |||
) |
return all the rr with a specific type and type from a packet.
Optionally specify from which section in the packet
[in] | packet | the packet |
[in] | ownername | the name |
[in] | type | the type |
[in] | sec | the packet's section |
Definition at line 316 of file packet.c.
References ldns_pkt_get_section_clone(), ldns_rdf_compare(), ldns_rr_clone(), ldns_rr_get_type(), ldns_rr_list_deep_free(), ldns_rr_list_free(), ldns_rr_list_new(), ldns_rr_list_push_rr(), ldns_rr_list_rr(), ldns_rr_list_rr_count(), and ldns_rr_owner().
bool ldns_pkt_rr | ( | ldns_pkt * | pkt, | |
ldns_pkt_section | sec, | |||
ldns_rr * | rr | |||
) |
check to see if an rr exist in the packet
[in] | pkt | the packet to examine |
[in] | sec | in which section to look |
[in] | rr | the rr to look for |
Definition at line 350 of file packet.c.
References ldns_pkt_get_section_clone(), ldns_rr_compare(), ldns_rr_list_rr(), and ldns_rr_list_rr_count().
sets the flags in a packet.
[in] | pkt | the packet to operate on |
[in] | flags | ORed values: LDNS_QR| LDNS_AR for instance |
Definition at line 790 of file packet.c.
References LDNS_AA, LDNS_AD, LDNS_CD, ldns_pkt_set_aa(), ldns_pkt_set_ad(), ldns_pkt_set_cd(), ldns_pkt_set_qr(), ldns_pkt_set_ra(), ldns_pkt_set_rd(), ldns_pkt_set_tc(), LDNS_QR, LDNS_RA, LDNS_RD, and LDNS_TC.
void ldns_pkt_set_id | ( | ldns_pkt * | p, | |
uint16_t | id | |||
) |
Set the packet's id.
[in] | p | the packet |
[in] | id | the id to set |
Definition at line 439 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_id.
void ldns_pkt_set_random_id | ( | ldns_pkt * | p | ) |
Set the packet's id to a random value.
[in] | p | the packet |
Definition at line 445 of file packet.c.
References LDNS_FREE, ldns_pkt_set_id(), and LDNS_XMALLOC.
Set the packet's qr bit.
[in] | p | the packet |
[in] | b | the value to set (boolean) |
Definition at line 465 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_qr.
Set the packet's aa bit.
[in] | p | the packet |
[in] | b | the value to set (boolean) |
Definition at line 471 of file packet.c.
References ldns_struct_hdr::_aa, and ldns_struct_pkt::_header.
Set the packet's tc bit.
[in] | p | the packet |
[in] | b | the value to set (boolean) |
Definition at line 477 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_tc.
Set the packet's rd bit.
[in] | p | the packet |
[in] | b | the value to set (boolean) |
Definition at line 483 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_rd.
Set the packet's cd bit.
[in] | p | the packet |
[in] | b | the value to set (boolean) |
Definition at line 513 of file packet.c.
References ldns_struct_hdr::_cd, and ldns_struct_pkt::_header.
Set the packet's ra bit.
[in] | p | the packet |
[in] | b | the value to set (boolean) |
Definition at line 519 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_ra.
Set the packet's ad bit.
[in] | p | the packet |
[in] | b | the value to set (boolean) |
Definition at line 525 of file packet.c.
References ldns_struct_hdr::_ad, and ldns_struct_pkt::_header.
void ldns_pkt_set_opcode | ( | ldns_pkt * | p, | |
ldns_pkt_opcode | c | |||
) |
Set the packet's opcode.
[in] | p | the packet |
[in] | c | the opcode |
Definition at line 531 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_opcode.
void ldns_pkt_set_rcode | ( | ldns_pkt * | p, | |
uint8_t | c | |||
) |
Set the packet's respons code.
[in] | p | the packet |
[in] | c | the rcode |
Definition at line 537 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_rcode.
void ldns_pkt_set_qdcount | ( | ldns_pkt * | p, | |
uint16_t | c | |||
) |
Set the packet's qd count.
[in] | p | the packet |
[in] | c | the count |
Definition at line 543 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_qdcount.
void ldns_pkt_set_ancount | ( | ldns_pkt * | p, | |
uint16_t | c | |||
) |
Set the packet's an count.
[in] | p | the packet |
[in] | c | the count |
Definition at line 549 of file packet.c.
References ldns_struct_hdr::_ancount, and ldns_struct_pkt::_header.
void ldns_pkt_set_nscount | ( | ldns_pkt * | p, | |
uint16_t | c | |||
) |
Set the packet's ns count.
[in] | p | the packet |
[in] | c | the count |
Definition at line 555 of file packet.c.
References ldns_struct_pkt::_header, and ldns_struct_hdr::_nscount.
void ldns_pkt_set_arcount | ( | ldns_pkt * | p, | |
uint16_t | c | |||
) |
Set the packet's arcount.
[in] | p | the packet |
[in] | c | the count |
Definition at line 561 of file packet.c.
References ldns_struct_hdr::_arcount, and ldns_struct_pkt::_header.
Set the packet's answering server.
[in] | p | the packet |
[in] | r | the address |
Definition at line 573 of file packet.c.
References ldns_struct_pkt::_answerfrom.
void ldns_pkt_set_querytime | ( | ldns_pkt * | p, | |
uint32_t | t | |||
) |
Set the packet's query time.
[in] | p | the packet |
[in] | t | the querytime in msec |
Definition at line 567 of file packet.c.
References ldns_struct_pkt::_querytime.
void ldns_pkt_set_size | ( | ldns_pkt * | p, | |
size_t | s | |||
) |
Set the packet's size.
[in] | p | the packet |
[in] | s | the size |
Definition at line 586 of file packet.c.
References ldns_struct_pkt::_size.
void ldns_pkt_set_timestamp | ( | ldns_pkt * | p, | |
struct | timeval | |||
) |
Set the packet's timestamp.
[in] | p | the packet |
[in] | timeval | the timestamp |
void ldns_pkt_set_section_count | ( | ldns_pkt * | p, | |
ldns_pkt_section | s, | |||
uint16_t | x | |||
) |
Set a packet's section count to x.
[in] | p | the packet |
[in] | s | the section |
[in] | x | the section count |
Definition at line 622 of file packet.c.
References ldns_pkt_set_ancount(), ldns_pkt_set_arcount(), ldns_pkt_set_nscount(), ldns_pkt_set_qdcount(), LDNS_SECTION_ADDITIONAL, LDNS_SECTION_ANSWER, LDNS_SECTION_ANY, LDNS_SECTION_ANY_NOQUESTION, LDNS_SECTION_AUTHORITY, and LDNS_SECTION_QUESTION.
Set the packet's tsig rr.
[in] | p | the packet |
[in] | t | the tsig rr |
Definition at line 643 of file packet.c.
References ldns_struct_pkt::_tsig_rr.
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.
[in] | p | the packet to examine |
Definition at line 911 of file packet.c.
References LDNS_PACKET_ANSWER, LDNS_PACKET_NODATA, LDNS_PACKET_NXDOMAIN, LDNS_PACKET_REFERRAL, LDNS_PACKET_UNKNOWN, ldns_pkt_ancount(), ldns_pkt_arcount(), ldns_pkt_get_rcode(), ldns_pkt_nscount(), ldns_pkt_rr_list_by_type(), LDNS_RCODE_NXDOMAIN, ldns_rr_list_deep_free(), LDNS_RR_TYPE_NS, LDNS_RR_TYPE_SOA, and LDNS_SECTION_AUTHORITY.
uint16_t ldns_pkt_edns_udp_size | ( | const ldns_pkt * | packet | ) |
return the packet's edns udp size
[in] | packet | the packet |
Definition at line 206 of file packet.c.
References ldns_struct_pkt::_edns_udp_size.
uint8_t ldns_pkt_edns_extended_rcode | ( | const ldns_pkt * | packet | ) |
return the packet's edns extended rcode
[in] | packet | the packet |
Definition at line 212 of file packet.c.
References ldns_struct_pkt::_edns_extended_rcode.
uint8_t ldns_pkt_edns_version | ( | const ldns_pkt * | packet | ) |
return the packet's edns version
[in] | packet | the packet |
Definition at line 218 of file packet.c.
References ldns_struct_pkt::_edns_version.
uint16_t ldns_pkt_edns_z | ( | const ldns_pkt * | packet | ) |
return the packet's edns z value
[in] | packet | the packet |
Definition at line 224 of file packet.c.
References ldns_struct_pkt::_edns_z.
return the packet's edns data
[in] | packet | the packet |
Definition at line 246 of file packet.c.
References ldns_struct_pkt::_edns_data.
return the packet's edns do bit
[in] | packet | the packet |
Definition at line 230 of file packet.c.
References ldns_struct_pkt::_edns_z, and LDNS_EDNS_MASK_DO_BIT.
Set the packet's edns do bit.
[in] | packet | the packet |
[in] | value | the bit's new value |
Definition at line 236 of file packet.c.
References ldns_struct_pkt::_edns_z, and LDNS_EDNS_MASK_DO_BIT.
returns true if this packet needs and EDNS rr to be sent.
At the moment the only reason is an expected packet size larger than 512 bytes, but for instance dnssec would be a good reason too.
[in] | packet | the packet to check |
Definition at line 713 of file packet.c.
References ldns_pkt_edns_data(), ldns_pkt_edns_extended_rcode(), and ldns_pkt_edns_udp_size().
void ldns_pkt_set_edns_udp_size | ( | ldns_pkt * | packet, | |
uint16_t | s | |||
) |
Set the packet's edns udp size.
[in] | packet | the packet |
[in] | s | the size |
Definition at line 592 of file packet.c.
References ldns_struct_pkt::_edns_udp_size.
void ldns_pkt_set_edns_extended_rcode | ( | ldns_pkt * | packet, | |
uint8_t | c | |||
) |
Set the packet's edns extended rcode.
[in] | packet | the packet |
[in] | c | the code |
Definition at line 598 of file packet.c.
References ldns_struct_pkt::_edns_extended_rcode.
void ldns_pkt_set_edns_version | ( | ldns_pkt * | packet, | |
uint8_t | v | |||
) |
Set the packet's edns version.
[in] | packet | the packet |
[in] | v | the version |
Definition at line 604 of file packet.c.
References ldns_struct_pkt::_edns_version.
void ldns_pkt_set_edns_z | ( | ldns_pkt * | packet, | |
uint16_t | z | |||
) |
Set the packet's edns z value.
[in] | packet | the packet |
[in] | z | the value |
Definition at line 610 of file packet.c.
References ldns_struct_pkt::_edns_z.
Set the packet's edns data.
[in] | packet | the packet |
[in] | data | the data |
Definition at line 616 of file packet.c.
References ldns_struct_pkt::_edns_data.
ldns_pkt* ldns_pkt_new | ( | ) |
allocates and initializes a ldns_pkt structure.
Definition at line 724 of file packet.c.
References ldns_struct_pkt::_additional, ldns_struct_pkt::_answer, ldns_struct_pkt::_authority, ldns_struct_pkt::_header, ldns_struct_pkt::_question, LDNS_FREE, LDNS_MALLOC, LDNS_PACKET_QUERY, ldns_pkt_set_aa(), ldns_pkt_set_ad(), ldns_pkt_set_answerfrom(), ldns_pkt_set_cd(), ldns_pkt_set_edns_data(), ldns_pkt_set_edns_extended_rcode(), ldns_pkt_set_edns_udp_size(), ldns_pkt_set_edns_version(), ldns_pkt_set_edns_z(), ldns_pkt_set_id(), ldns_pkt_set_opcode(), ldns_pkt_set_qr(), ldns_pkt_set_querytime(), ldns_pkt_set_ra(), ldns_pkt_set_rcode(), ldns_pkt_set_rd(), ldns_pkt_set_section_count(), ldns_pkt_set_size(), ldns_pkt_set_tc(), ldns_pkt_set_tsig(), ldns_rr_list_new(), LDNS_SECTION_ADDITIONAL, LDNS_SECTION_ANSWER, LDNS_SECTION_AUTHORITY, LDNS_SECTION_QUESTION, and ldns_struct_pkt::timestamp.
void ldns_pkt_free | ( | ldns_pkt * | packet | ) |
frees the packet structure and all data that it contains.
[in] | packet | The packet structure to free |
Definition at line 776 of file packet.c.
References ldns_struct_pkt::_additional, ldns_struct_pkt::_answer, ldns_struct_pkt::_authority, ldns_struct_pkt::_header, ldns_struct_pkt::_question, ldns_struct_pkt::_tsig_rr, LDNS_FREE, ldns_rr_free(), and ldns_rr_list_deep_free().
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.
[out] | p | the packet to be returned |
[in] | rr_name | the name to query for (as string) |
[in] | rr_type | the type to query for |
[in] | rr_class | the class to query for |
[in] | flags | packet flags |
Definition at line 820 of file packet.c.
References ldns_struct_pkt::_tsig_rr, ldns_pkt_free(), ldns_pkt_new(), ldns_pkt_push_rr(), ldns_pkt_set_answerfrom(), ldns_pkt_set_flags(), LDNS_RR_CLASS_IN, ldns_rr_free(), ldns_rr_new(), ldns_rr_set_class(), ldns_rr_set_owner(), ldns_rr_set_type(), LDNS_RR_TYPE_A, LDNS_SECTION_QUESTION, LDNS_STATUS_ERR, LDNS_STATUS_MEM_ERR, LDNS_STATUS_NULL, LDNS_STATUS_OK, and ldns_str2rdf_dname().
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.
[in] | rr_name | the name to query for |
[in] | rr_type | the type to query for |
[in] | rr_class | the class to query for |
[in] | flags | packet flags |
Definition at line 872 of file packet.c.
References ldns_struct_pkt::_tsig_rr, ldns_pkt_new(), ldns_pkt_push_rr(), ldns_pkt_set_flags(), LDNS_RR_CLASS_IN, ldns_rr_new(), ldns_rr_set_class(), ldns_rr_set_owner(), ldns_rr_set_type(), LDNS_RR_TYPE_A, and LDNS_SECTION_QUESTION.
clones the given packet, creating a fully allocated copy
[in] | pkt | the packet to clone |
Definition at line 957 of file packet.c.
References ldns_struct_pkt::_additional, ldns_struct_pkt::_answer, ldns_struct_pkt::_authority, ldns_struct_pkt::_question, ldns_pkt_aa(), ldns_pkt_ad(), ldns_pkt_additional(), ldns_pkt_ancount(), ldns_pkt_answer(), ldns_pkt_answerfrom(), ldns_pkt_arcount(), ldns_pkt_authority(), ldns_pkt_cd(), ldns_pkt_get_opcode(), ldns_pkt_get_rcode(), ldns_pkt_id(), ldns_pkt_new(), ldns_pkt_nscount(), ldns_pkt_qdcount(), ldns_pkt_qr(), ldns_pkt_querytime(), ldns_pkt_question(), ldns_pkt_ra(), ldns_pkt_rd(), ldns_pkt_set_aa(), ldns_pkt_set_ad(), ldns_pkt_set_ancount(), ldns_pkt_set_answerfrom(), ldns_pkt_set_arcount(), ldns_pkt_set_cd(), ldns_pkt_set_id(), ldns_pkt_set_nscount(), ldns_pkt_set_opcode(), ldns_pkt_set_qdcount(), ldns_pkt_set_qr(), ldns_pkt_set_querytime(), ldns_pkt_set_ra(), ldns_pkt_set_rcode(), ldns_pkt_set_rd(), ldns_pkt_set_size(), ldns_pkt_set_tc(), ldns_pkt_set_tsig(), ldns_pkt_size(), ldns_pkt_tc(), ldns_pkt_tsig(), ldns_rr_list_clone(), and ldns_rr_list_deep_free().
void ldns_pkt_set_additional | ( | ldns_pkt * | p, | |
ldns_rr_list * | rr | |||
) |
directly set the additional section
[in] | p | packet to operate on |
[in] | rr | rrlist to set |
Definition at line 489 of file packet.c.
References ldns_struct_pkt::_additional.
void ldns_pkt_set_answer | ( | ldns_pkt * | p, | |
ldns_rr_list * | rr | |||
) |
directly set the answer section
[in] | p | packet to operate on |
[in] | rr | rrlist to set |
Definition at line 501 of file packet.c.
References ldns_struct_pkt::_answer.
void ldns_pkt_set_question | ( | ldns_pkt * | p, | |
ldns_rr_list * | rr | |||
) |
directly set the question section
[in] | p | packet to operate on |
[in] | rr | rrlist to set |
Definition at line 495 of file packet.c.
References ldns_struct_pkt::_question.
void ldns_pkt_set_authority | ( | ldns_pkt * | p, | |
ldns_rr_list * | rr | |||
) |
directly set the auhority section
[in] | p | packet to operate on |
[in] | rr | rrlist to set |
Definition at line 507 of file packet.c.
References ldns_struct_pkt::_authority.
bool ldns_pkt_push_rr | ( | ldns_pkt * | packet, | |
ldns_pkt_section | section, | |||
ldns_rr * | rr | |||
) |
push an rr on a packet
[in] | packet | packet to operate on |
[in] | section | where to put it |
[in] | rr | rr to push |
Definition at line 649 of file packet.c.
References ldns_pkt_additional(), ldns_pkt_ancount(), ldns_pkt_answer(), ldns_pkt_arcount(), ldns_pkt_authority(), ldns_pkt_nscount(), ldns_pkt_qdcount(), ldns_pkt_question(), ldns_pkt_set_ancount(), ldns_pkt_set_arcount(), ldns_pkt_set_nscount(), ldns_pkt_set_qdcount(), ldns_rr_list_push_rr(), LDNS_SECTION_ADDITIONAL, LDNS_SECTION_ANSWER, LDNS_SECTION_ANY, LDNS_SECTION_ANY_NOQUESTION, LDNS_SECTION_AUTHORITY, and LDNS_SECTION_QUESTION.
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.
[in] | pkt | packet to operate on |
[in] | sec | where to put it |
[in] | rr | rr to push |
Definition at line 677 of file packet.c.
References ldns_pkt_push_rr(), and ldns_pkt_rr().
bool ldns_pkt_push_rr_list | ( | ldns_pkt * | packet, | |
ldns_pkt_section | section, | |||
ldns_rr_list * | list | |||
) |
push a rr_list on a packet
[in] | packet | packet to operate on |
[in] | section | where to put it |
[in] | list | the rr_list to push |
Definition at line 689 of file packet.c.
References ldns_pkt_push_rr(), ldns_rr_list_rr(), and ldns_rr_list_rr_count().
bool 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.
[in] | pkt | packet to operate on |
[in] | sec | where to put it |
[in] | list | the rr_list to push |
Definition at line 701 of file packet.c.
References ldns_pkt_safe_push_rr(), ldns_rr_list_rr(), and ldns_rr_list_rr_count().
check if a packet is empty
[in] | p | packet |
Definition at line 399 of file packet.c.
References ldns_pkt_section_count(), and LDNS_SECTION_ANY.