packet.h File Reference

Contains the definition of ldns_pkt and its parts, as well as functions to manipulate those. More...

Go to the source code of this file.

Data Structures

struct  ldns_struct_hdr
 
struct  ldns_struct_pkt
 DNS packet. More...
 

Macros

#define LDNS_MAX_PACKETLEN   65535
 
#define LDNS_QR   1 /* Query Response flag */
 
#define LDNS_AA   2 /* Authoritative Answer - server flag */
 
#define LDNS_TC   4 /* TrunCated - server flag */
 
#define LDNS_RD   8 /* Recursion Desired - query flag */
 
#define LDNS_CD   16 /* Checking Disabled - query flag */
 
#define LDNS_RA   32 /* Recursion Available - server flag */
 
#define LDNS_AD   64 /* Authenticated Data - server flag */
 

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. More...
 
bool ldns_pkt_qr (const ldns_pkt *p)
 Read the packet's qr bit. More...
 
bool ldns_pkt_aa (const ldns_pkt *p)
 Read the packet's aa bit. More...
 
bool ldns_pkt_tc (const ldns_pkt *p)
 Read the packet's tc bit. More...
 
bool ldns_pkt_rd (const ldns_pkt *p)
 Read the packet's rd bit. More...
 
bool ldns_pkt_cd (const ldns_pkt *p)
 Read the packet's cd bit. More...
 
bool ldns_pkt_ra (const ldns_pkt *p)
 Read the packet's ra bit. More...
 
bool ldns_pkt_ad (const ldns_pkt *p)
 Read the packet's ad bit. More...
 
ldns_pkt_opcode ldns_pkt_get_opcode (const ldns_pkt *p)
 Read the packet's code. More...
 
ldns_pkt_rcode ldns_pkt_get_rcode (const ldns_pkt *p)
 Return the packet's response code. More...
 
uint16_t ldns_pkt_qdcount (const ldns_pkt *p)
 Return the packet's qd count. More...
 
uint16_t ldns_pkt_ancount (const ldns_pkt *p)
 Return the packet's an count. More...
 
uint16_t ldns_pkt_nscount (const ldns_pkt *p)
 Return the packet's ns count. More...
 
uint16_t ldns_pkt_arcount (const ldns_pkt *p)
 Return the packet's ar count. More...
 
ldns_rdfldns_pkt_answerfrom (const ldns_pkt *p)
 Return the packet's answerfrom. More...
 
struct timeval ldns_pkt_timestamp (const ldns_pkt *p)
 Return the packet's timestamp. More...
 
uint32_t ldns_pkt_querytime (const ldns_pkt *p)
 Return the packet's querytime. More...
 
size_t ldns_pkt_size (const ldns_pkt *p)
 Return the packet's size in bytes. More...
 
uint16_t ldns_pkt_section_count (const ldns_pkt *p, ldns_pkt_section s)
 Return the number of RRs in the given section. More...
 
ldns_rrldns_pkt_tsig (const ldns_pkt *p)
 Return the packet's tsig pseudo rr's. More...
 
ldns_rr_listldns_pkt_question (const ldns_pkt *p)
 Return the packet's question section. More...
 
ldns_rr_listldns_pkt_answer (const ldns_pkt *p)
 Return the packet's answer section. More...
 
ldns_rr_listldns_pkt_authority (const ldns_pkt *p)
 Return the packet's authority section. More...
 
ldns_rr_listldns_pkt_additional (const ldns_pkt *p)
 Return the packet's additional section. More...
 
ldns_rr_listldns_pkt_all (const ldns_pkt *p)
 Return the packet's question, answer, authority and additional sections concatenated, in a new rr_list clone. More...
 
ldns_rr_listldns_pkt_all_noquestion (const ldns_pkt *p)
 Return the packet's answer, authority and additional sections concatenated, in a new rr_list clone. More...
 
ldns_rr_listldns_pkt_get_section_clone (const ldns_pkt *p, ldns_pkt_section s)
 return all the rr_list's in the packet. More...
 
ldns_rr_listldns_pkt_rr_list_by_name (const ldns_pkt *p, const ldns_rdf *r, ldns_pkt_section s)
 return all the rr with a specific name from a packet. More...
 
ldns_rr_listldns_pkt_rr_list_by_type (const ldns_pkt *p, ldns_rr_type t, ldns_pkt_section s)
 return all the rr with a specific type from a packet. More...
 
ldns_rr_listldns_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. More...
 
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 More...
 
bool ldns_pkt_set_flags (ldns_pkt *pkt, uint16_t flags)
 sets the flags in a packet. More...
 
void ldns_pkt_set_id (ldns_pkt *p, uint16_t id)
 Set the packet's id. More...
 
void ldns_pkt_set_random_id (ldns_pkt *p)
 Set the packet's id to a random value. More...
 
void ldns_pkt_set_qr (ldns_pkt *p, bool b)
 Set the packet's qr bit. More...
 
void ldns_pkt_set_aa (ldns_pkt *p, bool b)
 Set the packet's aa bit. More...
 
void ldns_pkt_set_tc (ldns_pkt *p, bool b)
 Set the packet's tc bit. More...
 
void ldns_pkt_set_rd (ldns_pkt *p, bool b)
 Set the packet's rd bit. More...
 
void ldns_pkt_set_cd (ldns_pkt *p, bool b)
 Set the packet's cd bit. More...
 
void ldns_pkt_set_ra (ldns_pkt *p, bool b)
 Set the packet's ra bit. More...
 
void ldns_pkt_set_ad (ldns_pkt *p, bool b)
 Set the packet's ad bit. More...
 
void ldns_pkt_set_opcode (ldns_pkt *p, ldns_pkt_opcode c)
 Set the packet's opcode. More...
 
void ldns_pkt_set_rcode (ldns_pkt *p, uint8_t c)
 Set the packet's response code. More...
 
void ldns_pkt_set_qdcount (ldns_pkt *p, uint16_t c)
 Set the packet's qd count. More...
 
void ldns_pkt_set_ancount (ldns_pkt *p, uint16_t c)
 Set the packet's an count. More...
 
void ldns_pkt_set_nscount (ldns_pkt *p, uint16_t c)
 Set the packet's ns count. More...
 
void ldns_pkt_set_arcount (ldns_pkt *p, uint16_t c)
 Set the packet's arcount. More...
 
void ldns_pkt_set_answerfrom (ldns_pkt *p, ldns_rdf *r)
 Set the packet's answering server. More...
 
void ldns_pkt_set_querytime (ldns_pkt *p, uint32_t t)
 Set the packet's query time. More...
 
void ldns_pkt_set_size (ldns_pkt *p, size_t s)
 Set the packet's size. More...
 
void ldns_pkt_set_timestamp (ldns_pkt *p, struct timeval timeval)
 Set the packet's timestamp. More...
 
void ldns_pkt_set_section_count (ldns_pkt *p, ldns_pkt_section s, uint16_t x)
 Set a packet's section count to x. More...
 
void ldns_pkt_set_tsig (ldns_pkt *p, ldns_rr *t)
 Set the packet's tsig rr. More...
 
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, etc. More...
 
uint16_t ldns_pkt_edns_udp_size (const ldns_pkt *packet)
 return the packet's edns udp size More...
 
uint8_t ldns_pkt_edns_extended_rcode (const ldns_pkt *packet)
 return the packet's edns extended rcode More...
 
uint8_t ldns_pkt_edns_version (const ldns_pkt *packet)
 return the packet's edns version More...
 
uint16_t ldns_pkt_edns_z (const ldns_pkt *packet)
 return the packet's edns z value More...
 
ldns_rdfldns_pkt_edns_data (const ldns_pkt *packet)
 return the packet's EDNS data More...
 
bool ldns_pkt_edns_do (const ldns_pkt *packet)
 return the packet's edns do bit More...
 
void ldns_pkt_set_edns_do (ldns_pkt *packet, bool value)
 Set the packet's edns do bit. More...
 
uint16_t ldns_pkt_edns_unassigned (const ldns_pkt *packet)
 return the packet's EDNS header bits that are unassigned. More...
 
void ldns_pkt_set_edns_unassigned (ldns_pkt *packet, uint16_t value)
 Set the packet's EDNS header bits that are unassigned. More...
 
bool ldns_pkt_edns (const ldns_pkt *packet)
 returns true if this packet needs and EDNS rr to be sent. More...
 
ldns_edns_option_listldns_pkt_edns_get_option_list (ldns_pkt *packet)
 Returns a list of structured EDNS options. More...
 
void ldns_pkt_set_edns_udp_size (ldns_pkt *packet, uint16_t s)
 Set the packet's edns udp size. More...
 
void ldns_pkt_set_edns_extended_rcode (ldns_pkt *packet, uint8_t c)
 Set the packet's edns extended rcode. More...
 
void ldns_pkt_set_edns_version (ldns_pkt *packet, uint8_t v)
 Set the packet's edns version. More...
 
void ldns_pkt_set_edns_z (ldns_pkt *packet, uint16_t z)
 Set the packet's edns z value. More...
 
void ldns_pkt_set_edns_data (ldns_pkt *packet, ldns_rdf *data)
 Set the packet's EDNS data. More...
 
void ldns_pkt_set_edns_option_list (ldns_pkt *packet, ldns_edns_option_list *list)
 Set the packet's structured EDNS data. More...
 
ldns_pktldns_pkt_new (void)
 allocates and initializes a ldns_pkt structure. More...
 
void ldns_pkt_free (ldns_pkt *packet)
 frees the packet structure and all data that it contains. More...
 
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. More...
 
ldns_status ldns_pkt_ixfr_request_new_frm_str (ldns_pkt **p, const char *rr_name, ldns_rr_class rr_class, uint16_t flags, ldns_rr *soa)
 creates an IXFR request packet for the given name, class. More...
 
ldns_pktldns_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. More...
 
ldns_pktldns_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. More...
 
ldns_pktldns_pkt_clone (const ldns_pkt *pkt)
 clones the given packet, creating a fully allocated copy More...
 
void ldns_pkt_set_additional (ldns_pkt *p, ldns_rr_list *rr)
 directly set the additional section More...
 
void ldns_pkt_set_answer (ldns_pkt *p, ldns_rr_list *rr)
 directly set the answer section More...
 
void ldns_pkt_set_question (ldns_pkt *p, ldns_rr_list *rr)
 directly set the question section More...
 
void ldns_pkt_set_authority (ldns_pkt *p, ldns_rr_list *rr)
 directly set the authority section More...
 
bool ldns_pkt_push_rr (ldns_pkt *packet, ldns_pkt_section section, ldns_rr *rr)
 push an rr on a packet More...
 
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. More...
 
bool ldns_pkt_push_rr_list (ldns_pkt *packet, ldns_pkt_section section, ldns_rr_list *list)
 push a rr_list on a packet More...
 
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. More...
 
bool ldns_pkt_empty (ldns_pkt *p)
 check if a packet is empty More...
 

Detailed Description

Contains the definition of ldns_pkt and its parts, as well as functions to manipulate those.

Definition in file packet.h.

Macro Definition Documentation

◆ LDNS_MAX_PACKETLEN

#define LDNS_MAX_PACKETLEN   65535

Definition at line 24 of file packet.h.

◆ LDNS_QR

#define LDNS_QR   1 /* Query Response flag */

Definition at line 27 of file packet.h.

◆ LDNS_AA

#define LDNS_AA   2 /* Authoritative Answer - server flag */

Definition at line 28 of file packet.h.

◆ LDNS_TC

#define LDNS_TC   4 /* TrunCated - server flag */

Definition at line 29 of file packet.h.

◆ LDNS_RD

#define LDNS_RD   8 /* Recursion Desired - query flag */

Definition at line 30 of file packet.h.

◆ LDNS_CD

#define LDNS_CD   16 /* Checking Disabled - query flag */

Definition at line 31 of file packet.h.

◆ LDNS_RA

#define LDNS_RA   32 /* Recursion Available - server flag */

Definition at line 32 of file packet.h.

◆ LDNS_AD

#define LDNS_AD   64 /* Authenticated Data - server flag */

Definition at line 33 of file packet.h.

Typedef Documentation

◆ ldns_pkt_opcode

Definition at line 1 of file packet.h.

◆ ldns_pkt_rcode

Definition at line 1 of file packet.h.

◆ ldns_hdr

typedef struct ldns_struct_hdr ldns_hdr

Definition at line 1 of file packet.h.

◆ ldns_pkt

typedef struct ldns_struct_pkt ldns_pkt

Definition at line 1 of file packet.h.

◆ ldns_pkt_section

Definition at line 1 of file packet.h.

◆ ldns_pkt_type

Definition at line 1 of file packet.h.

Enumeration Type Documentation

◆ ldns_enum_pkt_opcode

Enumerator
LDNS_PACKET_QUERY 
LDNS_PACKET_IQUERY 
LDNS_PACKET_STATUS 
LDNS_PACKET_NOTIFY 
LDNS_PACKET_UPDATE 

Definition at line 46 of file packet.h.

◆ ldns_enum_pkt_rcode

Enumerator
LDNS_RCODE_NOERROR 
LDNS_RCODE_FORMERR 
LDNS_RCODE_SERVFAIL 
LDNS_RCODE_NXDOMAIN 
LDNS_RCODE_NOTIMPL 
LDNS_RCODE_REFUSED 
LDNS_RCODE_YXDOMAIN 
LDNS_RCODE_YXRRSET 
LDNS_RCODE_NXRRSET 
LDNS_RCODE_NOTAUTH 
LDNS_RCODE_NOTZONE 

Definition at line 56 of file packet.h.

◆ ldns_enum_pkt_section

The sections of a packet.

Enumerator
LDNS_SECTION_QUESTION 
LDNS_SECTION_ANSWER 
LDNS_SECTION_AUTHORITY 
LDNS_SECTION_ADDITIONAL 
LDNS_SECTION_ANY 

bogus section, if not interested

LDNS_SECTION_ANY_NOQUESTION 

used to get all non-question rrs from a packet

Definition at line 277 of file packet.h.

◆ ldns_enum_pkt_type

The different types of packets.

Enumerator
LDNS_PACKET_QUESTION 
LDNS_PACKET_REFERRAL 
LDNS_PACKET_ANSWER 
LDNS_PACKET_NXDOMAIN 
LDNS_PACKET_NODATA 
LDNS_PACKET_UNKNOWN 

Definition at line 292 of file packet.h.

Function Documentation

◆ ldns_pkt_id()

uint16_t ldns_pkt_id ( const ldns_pkt p)

Read the packet id.

Parameters
[in]pthe packet
Returns
the packet id

Definition at line 40 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_id.

◆ ldns_pkt_qr()

bool ldns_pkt_qr ( const ldns_pkt p)

Read the packet's qr bit.

Parameters
[in]pthe packet
Returns
value of the bit

Definition at line 46 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_qr.

◆ ldns_pkt_aa()

bool ldns_pkt_aa ( const ldns_pkt p)

Read the packet's aa bit.

Parameters
[in]pthe packet
Returns
value of the bit

Definition at line 52 of file packet.c.

References ldns_struct_hdr::_aa, and ldns_struct_pkt::_header.

◆ ldns_pkt_tc()

bool ldns_pkt_tc ( const ldns_pkt p)

Read the packet's tc bit.

Parameters
[in]pthe packet
Returns
value of the bit

Definition at line 58 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_tc.

◆ ldns_pkt_rd()

bool ldns_pkt_rd ( const ldns_pkt p)

Read the packet's rd bit.

Parameters
[in]pthe packet
Returns
value of the bit

Definition at line 64 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_rd.

◆ ldns_pkt_cd()

bool ldns_pkt_cd ( const ldns_pkt p)

Read the packet's cd bit.

Parameters
[in]pthe packet
Returns
value of the bit

Definition at line 70 of file packet.c.

References ldns_struct_hdr::_cd, and ldns_struct_pkt::_header.

◆ ldns_pkt_ra()

bool ldns_pkt_ra ( const ldns_pkt p)

Read the packet's ra bit.

Parameters
[in]pthe packet
Returns
value of the bit

Definition at line 76 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_ra.

◆ ldns_pkt_ad()

bool ldns_pkt_ad ( const ldns_pkt p)

Read the packet's ad bit.

Parameters
[in]pthe packet
Returns
value of the bit

Definition at line 82 of file packet.c.

References ldns_struct_hdr::_ad, and ldns_struct_pkt::_header.

◆ ldns_pkt_get_opcode()

ldns_pkt_opcode ldns_pkt_get_opcode ( const ldns_pkt p)

Read the packet's code.

Parameters
[in]pthe packet
Returns
the opcode

Definition at line 88 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_opcode.

◆ ldns_pkt_get_rcode()

ldns_pkt_rcode ldns_pkt_get_rcode ( const ldns_pkt p)

Return the packet's response code.

Parameters
[in]pthe packet
Returns
the response code

Definition at line 94 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_rcode.

◆ ldns_pkt_qdcount()

uint16_t ldns_pkt_qdcount ( const ldns_pkt p)

Return the packet's qd count.

Parameters
[in]pthe packet
Returns
the qd count

Definition at line 100 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_qdcount.

◆ ldns_pkt_ancount()

uint16_t ldns_pkt_ancount ( const ldns_pkt p)

Return the packet's an count.

Parameters
[in]pthe packet
Returns
the an count

Definition at line 106 of file packet.c.

References ldns_struct_hdr::_ancount, and ldns_struct_pkt::_header.

◆ ldns_pkt_nscount()

uint16_t ldns_pkt_nscount ( const ldns_pkt p)

Return the packet's ns count.

Parameters
[in]pthe packet
Returns
the ns count

Definition at line 112 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_nscount.

◆ ldns_pkt_arcount()

uint16_t ldns_pkt_arcount ( const ldns_pkt p)

Return the packet's ar count.

Parameters
[in]pthe packet
Returns
the ar count

Definition at line 118 of file packet.c.

References ldns_struct_hdr::_arcount, and ldns_struct_pkt::_header.

◆ ldns_pkt_answerfrom()

ldns_rdf* ldns_pkt_answerfrom ( const ldns_pkt p)

Return the packet's answerfrom.

Parameters
[in]ppacket
Returns
the name of the server

Definition at line 195 of file packet.c.

References ldns_struct_pkt::_answerfrom.

◆ ldns_pkt_timestamp()

struct timeval ldns_pkt_timestamp ( const ldns_pkt p)

Return the packet's timestamp.

Parameters
[in]pthe packet
Returns
the timestamp

Definition at line 195 of file packet.c.

◆ ldns_pkt_querytime()

uint32_t ldns_pkt_querytime ( const ldns_pkt p)

Return the packet's querytime.

Parameters
[in]pthe packet
Returns
the querytime

Definition at line 189 of file packet.c.

References ldns_struct_pkt::_querytime.

◆ ldns_pkt_size()

size_t ldns_pkt_size ( const ldns_pkt p)

Return the packet's size in bytes.

Parameters
[in]pthe packet
Returns
the size

Definition at line 183 of file packet.c.

References ldns_struct_pkt::_size.

◆ ldns_pkt_section_count()

uint16_t ldns_pkt_section_count ( const ldns_pkt p,
ldns_pkt_section  s 
)

Return the number of RRs in the given section.

Returns the sum of all RRs when LDNS_SECTION_ANY is given. Returns the sum of all non-question RRs when LDNS_SECTION_ANY_NOQUESTION is given.

Parameters
[in]pthe packet
[in]sthe section
Returns
the number of RRs in the given section

Definition at line 404 of file packet.c.

References ldns_pkt_ancount(), ldns_pkt_arcount(), ldns_pkt_nscount(), ldns_pkt_qdcount(), LDNS_SECTION_ADDITIONAL, LDNS_SECTION_ANSWER, LDNS_SECTION_ANY, LDNS_SECTION_ANY_NOQUESTION, LDNS_SECTION_AUTHORITY, and LDNS_SECTION_QUESTION.

◆ ldns_pkt_tsig()

ldns_rr* ldns_pkt_tsig ( const ldns_pkt p)

Return the packet's tsig pseudo rr's.

Parameters
[in]pthe packet
Returns
the tsig rr

Definition at line 465 of file packet.c.

References ldns_struct_pkt::_tsig_rr.

◆ ldns_pkt_question()

ldns_rr_list* ldns_pkt_question ( const ldns_pkt p)

Return the packet's question section.

Parameters
[in]pthe packet
Returns
the section

Definition at line 124 of file packet.c.

References ldns_struct_pkt::_question.

◆ ldns_pkt_answer()

ldns_rr_list* ldns_pkt_answer ( const ldns_pkt p)

Return the packet's answer section.

Parameters
[in]pthe packet
Returns
the section

Definition at line 130 of file packet.c.

References ldns_struct_pkt::_answer.

◆ ldns_pkt_authority()

ldns_rr_list* ldns_pkt_authority ( const ldns_pkt p)

Return the packet's authority section.

Parameters
[in]pthe packet
Returns
the section

Definition at line 136 of file packet.c.

References ldns_struct_pkt::_authority.

◆ ldns_pkt_additional()

ldns_rr_list* ldns_pkt_additional ( const ldns_pkt p)

Return the packet's additional section.

Parameters
[in]pthe packet
Returns
the section

Definition at line 142 of file packet.c.

References ldns_struct_pkt::_additional.

◆ ldns_pkt_all()

ldns_rr_list* ldns_pkt_all ( const ldns_pkt p)

Return the packet's question, answer, authority and additional sections concatenated, in a new rr_list clone.

Parameters
[in]pthe packet
Returns
the rrs

Definition at line 149 of file packet.c.

References ldns_pkt_additional(), ldns_pkt_answer(), ldns_pkt_authority(), ldns_pkt_question(), ldns_rr_list_cat_clone(), and ldns_rr_list_deep_free().

◆ ldns_pkt_all_noquestion()

ldns_rr_list* ldns_pkt_all_noquestion ( const ldns_pkt p)

Return the packet's answer, authority and additional sections concatenated, in a new rr_list clone.

Like ldns_pkt_all but without the questions.

Parameters
[in]pthe packet
Returns
the rrs except the question rrs

Definition at line 168 of file packet.c.

References ldns_pkt_additional(), ldns_pkt_answer(), ldns_pkt_authority(), ldns_rr_list_cat_clone(), and ldns_rr_list_deep_free().

◆ ldns_pkt_get_section_clone()

ldns_rr_list* ldns_pkt_get_section_clone ( const ldns_pkt p,
ldns_pkt_section  s 
)

return all the rr_list's in the packet.

Clone the lists, instead of returning pointers.

Parameters
[in]pthe packet to look in
[in]swhat section(s) to return
Returns
ldns_rr_list with the rr's or NULL if none were found

Definition at line 444 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_pkt_rr_list_by_name()

ldns_rr_list* ldns_pkt_rr_list_by_name ( const ldns_pkt p,
const 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

Parameters
[in]pthe packet
[in]rthe name
[in]sthe packet's section
Returns
a list with the rr's or NULL if none were found

Definition at line 267 of file packet.c.

References ldns_dname_compare(), ldns_pkt_get_section_clone(), ldns_rr_clone(), ldns_rr_list_deep_free(), ldns_rr_list_new(), ldns_rr_list_push_rr(), ldns_rr_list_rr(), ldns_rr_list_rr_count(), and ldns_rr_owner().

◆ ldns_pkt_rr_list_by_type()

ldns_rr_list* ldns_pkt_rr_list_by_type ( const 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

Parameters
[in]pthe packet
[in]tthe type
[in]sthe packet's section
Returns
a list with the rr's or NULL if none were found

Definition at line 304 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_pkt_rr_list_by_name_and_type()

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.

Optionally specify from which section in the packet

Parameters
[in]packetthe packet
[in]ownernamethe name
[in]typethe type
[in]secthe packet's section
Returns
a list with the rr's or NULL if none were found

Definition at line 340 of file packet.c.

References ldns_dname_compare(), 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(), ldns_rr_list_rr_count(), and ldns_rr_owner().

◆ ldns_pkt_rr()

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

Parameters
[in]pktthe packet to examine
[in]secin which section to look
[in]rrthe rr to look for

Definition at line 377 of file packet.c.

References ldns_pkt_additional(), ldns_pkt_answer(), ldns_pkt_authority(), ldns_pkt_question(), ldns_rr_list_contains_rr(), LDNS_SECTION_ADDITIONAL, LDNS_SECTION_ANSWER, LDNS_SECTION_ANY, LDNS_SECTION_ANY_NOQUESTION, LDNS_SECTION_AUTHORITY, and LDNS_SECTION_QUESTION.

◆ ldns_pkt_set_flags()

bool ldns_pkt_set_flags ( ldns_pkt pkt,
uint16_t  flags 
)

sets the flags in a packet.

Parameters
[in]pktthe packet to operate on
[in]flagsORed values: LDNS_QR| LDNS_AR for instance
Returns
true on success otherwise false

Definition at line 912 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.

◆ ldns_pkt_set_id()

void ldns_pkt_set_id ( ldns_pkt p,
uint16_t  id 
)

Set the packet's id.

Parameters
[in]pthe packet
[in]idthe id to set

Definition at line 471 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_id.

◆ ldns_pkt_set_random_id()

void ldns_pkt_set_random_id ( ldns_pkt p)

Set the packet's id to a random value.

Parameters
[in]pthe packet

Definition at line 477 of file packet.c.

References ldns_get_random(), and ldns_pkt_set_id().

◆ ldns_pkt_set_qr()

void ldns_pkt_set_qr ( ldns_pkt p,
bool  b 
)

Set the packet's qr bit.

Parameters
[in]pthe packet
[in]bthe value to set (boolean)

Definition at line 485 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_qr.

◆ ldns_pkt_set_aa()

void ldns_pkt_set_aa ( ldns_pkt p,
bool  b 
)

Set the packet's aa bit.

Parameters
[in]pthe packet
[in]bthe value to set (boolean)

Definition at line 491 of file packet.c.

References ldns_struct_hdr::_aa, and ldns_struct_pkt::_header.

◆ ldns_pkt_set_tc()

void ldns_pkt_set_tc ( ldns_pkt p,
bool  b 
)

Set the packet's tc bit.

Parameters
[in]pthe packet
[in]bthe value to set (boolean)

Definition at line 497 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_tc.

◆ ldns_pkt_set_rd()

void ldns_pkt_set_rd ( ldns_pkt p,
bool  b 
)

Set the packet's rd bit.

Parameters
[in]pthe packet
[in]bthe value to set (boolean)

Definition at line 503 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_rd.

◆ ldns_pkt_set_cd()

void ldns_pkt_set_cd ( ldns_pkt p,
bool  b 
)

Set the packet's cd bit.

Parameters
[in]pthe packet
[in]bthe value to set (boolean)

Definition at line 533 of file packet.c.

References ldns_struct_hdr::_cd, and ldns_struct_pkt::_header.

◆ ldns_pkt_set_ra()

void ldns_pkt_set_ra ( ldns_pkt p,
bool  b 
)

Set the packet's ra bit.

Parameters
[in]pthe packet
[in]bthe value to set (boolean)

Definition at line 539 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_ra.

◆ ldns_pkt_set_ad()

void ldns_pkt_set_ad ( ldns_pkt p,
bool  b 
)

Set the packet's ad bit.

Parameters
[in]pthe packet
[in]bthe value to set (boolean)

Definition at line 545 of file packet.c.

References ldns_struct_hdr::_ad, and ldns_struct_pkt::_header.

◆ ldns_pkt_set_opcode()

void ldns_pkt_set_opcode ( ldns_pkt p,
ldns_pkt_opcode  c 
)

Set the packet's opcode.

Parameters
[in]pthe packet
[in]cthe opcode

Definition at line 551 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_opcode.

◆ ldns_pkt_set_rcode()

void ldns_pkt_set_rcode ( ldns_pkt p,
uint8_t  c 
)

Set the packet's response code.

Parameters
[in]pthe packet
[in]cthe rcode

Definition at line 557 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_rcode.

◆ ldns_pkt_set_qdcount()

void ldns_pkt_set_qdcount ( ldns_pkt p,
uint16_t  c 
)

Set the packet's qd count.

Parameters
[in]pthe packet
[in]cthe count

Definition at line 563 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_qdcount.

◆ ldns_pkt_set_ancount()

void ldns_pkt_set_ancount ( ldns_pkt p,
uint16_t  c 
)

Set the packet's an count.

Parameters
[in]pthe packet
[in]cthe count

Definition at line 569 of file packet.c.

References ldns_struct_hdr::_ancount, and ldns_struct_pkt::_header.

◆ ldns_pkt_set_nscount()

void ldns_pkt_set_nscount ( ldns_pkt p,
uint16_t  c 
)

Set the packet's ns count.

Parameters
[in]pthe packet
[in]cthe count

Definition at line 575 of file packet.c.

References ldns_struct_pkt::_header, and ldns_struct_hdr::_nscount.

◆ ldns_pkt_set_arcount()

void ldns_pkt_set_arcount ( ldns_pkt p,
uint16_t  c 
)

Set the packet's arcount.

Parameters
[in]pthe packet
[in]cthe count

Definition at line 581 of file packet.c.

References ldns_struct_hdr::_arcount, and ldns_struct_pkt::_header.

◆ ldns_pkt_set_answerfrom()

void ldns_pkt_set_answerfrom ( ldns_pkt p,
ldns_rdf r 
)

Set the packet's answering server.

Parameters
[in]pthe packet
[in]rthe address

Definition at line 593 of file packet.c.

References ldns_struct_pkt::_answerfrom.

◆ ldns_pkt_set_querytime()

void ldns_pkt_set_querytime ( ldns_pkt p,
uint32_t  t 
)

Set the packet's query time.

Parameters
[in]pthe packet
[in]tthe querytime in msec

Definition at line 587 of file packet.c.

References ldns_struct_pkt::_querytime.

◆ ldns_pkt_set_size()

void ldns_pkt_set_size ( ldns_pkt p,
size_t  s 
)

Set the packet's size.

Parameters
[in]pthe packet
[in]sthe size

Definition at line 606 of file packet.c.

References ldns_struct_pkt::_size.

◆ ldns_pkt_set_timestamp()

void ldns_pkt_set_timestamp ( ldns_pkt p,
struct timeval  timeval 
)

Set the packet's timestamp.

Parameters
[in]pthe packet
[in]timevalthe timestamp

Definition at line 599 of file packet.c.

References ldns_struct_pkt::timestamp.

◆ ldns_pkt_set_section_count()

void ldns_pkt_set_section_count ( ldns_pkt p,
ldns_pkt_section  s,
uint16_t  x 
)

Set a packet's section count to x.

Parameters
[in]pthe packet
[in]sthe section
[in]xthe section count

Definition at line 651 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.

◆ ldns_pkt_set_tsig()

void ldns_pkt_set_tsig ( ldns_pkt p,
ldns_rr t 
)

Set the packet's tsig rr.

Parameters
[in]pthe packet
[in]tthe tsig rr

Definition at line 672 of file packet.c.

References ldns_struct_pkt::_tsig_rr.

◆ ldns_pkt_reply_type()

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, etc.

Parameters
[in]pthe packet to examine
Returns
the type of packet

Definition at line 1168 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.

◆ ldns_pkt_edns_udp_size()

uint16_t ldns_pkt_edns_udp_size ( const ldns_pkt packet)

return the packet's edns udp size

Parameters
[in]packetthe packet
Returns
the size

Definition at line 207 of file packet.c.

References ldns_struct_pkt::_edns_udp_size.

◆ ldns_pkt_edns_extended_rcode()

uint8_t ldns_pkt_edns_extended_rcode ( const ldns_pkt packet)

return the packet's edns extended rcode

Parameters
[in]packetthe packet
Returns
the rcode

Definition at line 213 of file packet.c.

References ldns_struct_pkt::_edns_extended_rcode.

◆ ldns_pkt_edns_version()

uint8_t ldns_pkt_edns_version ( const ldns_pkt packet)

return the packet's edns version

Parameters
[in]packetthe packet
Returns
the version

Definition at line 219 of file packet.c.

References ldns_struct_pkt::_edns_version.

◆ ldns_pkt_edns_z()

uint16_t ldns_pkt_edns_z ( const ldns_pkt packet)

return the packet's edns z value

Parameters
[in]packetthe packet
Returns
the z value

Definition at line 225 of file packet.c.

References ldns_struct_pkt::_edns_z.

◆ ldns_pkt_edns_data()

ldns_rdf* ldns_pkt_edns_data ( const ldns_pkt packet)

return the packet's EDNS data

Parameters
[in]packetthe packet
Returns
the data

Definition at line 260 of file packet.c.

References ldns_struct_pkt::_edns_data.

◆ ldns_pkt_edns_do()

bool ldns_pkt_edns_do ( const ldns_pkt packet)

return the packet's edns do bit

Parameters
[in]packetthe packet
Returns
the bit's value

Definition at line 231 of file packet.c.

References ldns_struct_pkt::_edns_z, and LDNS_EDNS_MASK_DO_BIT.

◆ ldns_pkt_set_edns_do()

void ldns_pkt_set_edns_do ( ldns_pkt packet,
bool  value 
)

Set the packet's edns do bit.

Parameters
[in]packetthe packet
[in]valuethe bit's new value

Definition at line 237 of file packet.c.

References ldns_struct_pkt::_edns_z, and LDNS_EDNS_MASK_DO_BIT.

◆ ldns_pkt_edns_unassigned()

uint16_t ldns_pkt_edns_unassigned ( const ldns_pkt packet)

return the packet's EDNS header bits that are unassigned.

Definition at line 247 of file packet.c.

References ldns_struct_pkt::_edns_z, and LDNS_EDNS_MASK_UNASSIGNED.

◆ ldns_pkt_set_edns_unassigned()

void ldns_pkt_set_edns_unassigned ( ldns_pkt packet,
uint16_t  value 
)

Set the packet's EDNS header bits that are unassigned.

Parameters
[in]packetthe packet
[in]valuethe value

Definition at line 253 of file packet.c.

References ldns_struct_pkt::_edns_z, and LDNS_EDNS_MASK_UNASSIGNED.

◆ ldns_pkt_edns()

bool ldns_pkt_edns ( const ldns_pkt packet)

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.

Parameters
[in]packetthe packet to check
Returns
true if packet needs edns rr

Definition at line 750 of file packet.c.

References ldns_struct_pkt::_edns_list, ldns_struct_pkt::_edns_present, ldns_pkt_edns_data(), ldns_pkt_edns_do(), ldns_pkt_edns_extended_rcode(), and ldns_pkt_edns_udp_size().

◆ ldns_pkt_edns_get_option_list()

ldns_edns_option_list* ldns_pkt_edns_get_option_list ( ldns_pkt packet)

Returns a list of structured EDNS options.

The list will be automatically freed when the packet is freed. The option list can be manipulated and will be used when converting the packet to wireformat with ldns_pkt2wire.

Parameters
[in]packetthe packet which contains the EDNS data
Returns
the list of EDNS options

Definition at line 821 of file packet.c.

References ldns_struct_pkt::_edns_list, ldns_pkt_edns_data(), and pkt_edns_data2edns_option_list().

◆ ldns_pkt_set_edns_udp_size()

void ldns_pkt_set_edns_udp_size ( ldns_pkt packet,
uint16_t  s 
)

Set the packet's edns udp size.

Parameters
[in]packetthe packet
[in]sthe size

Definition at line 612 of file packet.c.

References ldns_struct_pkt::_edns_udp_size.

◆ ldns_pkt_set_edns_extended_rcode()

void ldns_pkt_set_edns_extended_rcode ( ldns_pkt packet,
uint8_t  c 
)

Set the packet's edns extended rcode.

Parameters
[in]packetthe packet
[in]cthe code

Definition at line 618 of file packet.c.

References ldns_struct_pkt::_edns_extended_rcode.

◆ ldns_pkt_set_edns_version()

void ldns_pkt_set_edns_version ( ldns_pkt packet,
uint8_t  v 
)

Set the packet's edns version.

Parameters
[in]packetthe packet
[in]vthe version

Definition at line 624 of file packet.c.

References ldns_struct_pkt::_edns_version.

◆ ldns_pkt_set_edns_z()

void ldns_pkt_set_edns_z ( ldns_pkt packet,
uint16_t  z 
)

Set the packet's edns z value.

Parameters
[in]packetthe packet
[in]zthe value

Definition at line 630 of file packet.c.

References ldns_struct_pkt::_edns_z.

◆ ldns_pkt_set_edns_data()

void ldns_pkt_set_edns_data ( ldns_pkt packet,
ldns_rdf data 
)

Set the packet's EDNS data.

Parameters
[in]packetthe packet
[in]datathe data

Definition at line 636 of file packet.c.

References ldns_struct_pkt::_edns_data.

◆ ldns_pkt_set_edns_option_list()

void ldns_pkt_set_edns_option_list ( ldns_pkt packet,
ldns_edns_option_list list 
)

Set the packet's structured EDNS data.

Once an edns_option_list is set (or get), the option list will be used for converting into wireformat.

Parameters
[in]packetthe packet
[in]listthe options list that will create the data

Definition at line 642 of file packet.c.

References ldns_struct_pkt::_edns_list, and ldns_edns_option_list_deep_free().

◆ ldns_pkt_new()

◆ ldns_pkt_free()

◆ ldns_pkt_query_new_frm_str()

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.

Parameters
[out]pthe packet to be returned
[in]rr_namethe name to query for (as string)
[in]rr_typethe type to query for
[in]rr_classthe class to query for
[in]flagspacket flags
Returns
LDNS_STATUS_OK or a ldns_status mesg with the error

Definition at line 1081 of file packet.c.

◆ ldns_pkt_ixfr_request_new_frm_str()

ldns_status ldns_pkt_ixfr_request_new_frm_str ( ldns_pkt **  p,
const char *  rr_name,
ldns_rr_class  rr_class,
uint16_t  flags,
ldns_rr soa 
)

creates an IXFR request packet for the given name, class.

adds the SOA record to the authority section.

Parameters
[out]pthe packet to be returned
[in]rr_namethe name to query for (as string)
[in]rr_classthe class to query for
[in]flagspacket flags
[in]soasoa record to be added to the authority section (not copied).
Returns
LDNS_STATUS_OK or a ldns_status mesg with the error

Definition at line 1089 of file packet.c.

References LDNS_STATUS_OK, and ldns_str2rdf_dname().

◆ ldns_pkt_query_new()

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.

Parameters
[in]rr_namethe name to query for (not copied). The returned packet will take ownership of rr_name, so the caller should not free it.
[in]rr_typethe type to query for
[in]rr_classthe class to query for
[in]flagspacket flags
Returns
ldns_pkt* a pointer to the new pkt

Definition at line 1148 of file packet.c.

◆ ldns_pkt_ixfr_request_new()

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.

adds the SOA record to the authority section.

Parameters
[in]rr_namethe name to query for (not copied). The returned packet will take ownership of rr_name, so the caller should not free it.
[in]rr_classthe class to query for
[in]flagspacket flags
[in]soasoa record to be added to the authority section (not copied).
Returns
ldns_pkt* a pointer to the new pkt

Definition at line 1156 of file packet.c.

◆ ldns_pkt_clone()

ldns_pkt* ldns_pkt_clone ( const ldns_pkt pkt)

clones the given packet, creating a fully allocated copy

Parameters
[in]pktthe packet to clone
Returns
ldns_pkt* pointer to the new packet

Definition at line 1214 of file packet.c.

References ldns_struct_pkt::_additional, ldns_struct_pkt::_answer, ldns_struct_pkt::_authority, ldns_struct_pkt::_edns_list, ldns_struct_pkt::_edns_present, ldns_struct_pkt::_question, ldns_edns_option_list_clone(), 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_edns_data(), ldns_pkt_edns_do(), ldns_pkt_edns_extended_rcode(), ldns_pkt_edns_udp_size(), ldns_pkt_edns_version(), ldns_pkt_edns_z(), 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_edns_data(), ldns_pkt_set_edns_do(), ldns_pkt_set_edns_extended_rcode(), ldns_pkt_set_edns_option_list(), ldns_pkt_set_edns_udp_size(), ldns_pkt_set_edns_version(), ldns_pkt_set_edns_z(), 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_timestamp(), ldns_pkt_set_tsig(), ldns_pkt_size(), ldns_pkt_tc(), ldns_pkt_timestamp(), ldns_pkt_tsig(), ldns_rdf_clone(), ldns_rr_clone(), ldns_rr_list_clone(), and ldns_rr_list_deep_free().

◆ ldns_pkt_set_additional()

void ldns_pkt_set_additional ( ldns_pkt p,
ldns_rr_list rr 
)

directly set the additional section

Parameters
[in]ppacket to operate on
[in]rrrrlist to set

Definition at line 509 of file packet.c.

References ldns_struct_pkt::_additional.

◆ ldns_pkt_set_answer()

void ldns_pkt_set_answer ( ldns_pkt p,
ldns_rr_list rr 
)

directly set the answer section

Parameters
[in]ppacket to operate on
[in]rrrrlist to set

Definition at line 521 of file packet.c.

References ldns_struct_pkt::_answer.

◆ ldns_pkt_set_question()

void ldns_pkt_set_question ( ldns_pkt p,
ldns_rr_list rr 
)

directly set the question section

Parameters
[in]ppacket to operate on
[in]rrrrlist to set

Definition at line 515 of file packet.c.

References ldns_struct_pkt::_question.

◆ ldns_pkt_set_authority()

void ldns_pkt_set_authority ( ldns_pkt p,
ldns_rr_list rr 
)

directly set the authority section

Parameters
[in]ppacket to operate on
[in]rrrrlist to set

Definition at line 527 of file packet.c.

References ldns_struct_pkt::_authority.

◆ ldns_pkt_push_rr()

bool ldns_pkt_push_rr ( ldns_pkt packet,
ldns_pkt_section  section,
ldns_rr rr 
)

◆ ldns_pkt_safe_push_rr()

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.

Parameters
[in]pktpacket to operate on
[in]secwhere to put it
[in]rrrr to push
Returns
a boolean which is true when the rr was added

Definition at line 714 of file packet.c.

References ldns_pkt_push_rr(), and ldns_pkt_rr().

◆ ldns_pkt_push_rr_list()

bool ldns_pkt_push_rr_list ( ldns_pkt packet,
ldns_pkt_section  section,
ldns_rr_list list 
)

push a rr_list on a packet

Parameters
[in]packetpacket to operate on
[in]sectionwhere to put it
[in]listthe rr_list to push
Returns
a boolean which is true when the rr was added

Definition at line 726 of file packet.c.

References ldns_pkt_push_rr(), ldns_rr_list_rr(), and ldns_rr_list_rr_count().

◆ ldns_pkt_safe_push_rr_list()

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.

Parameters
[in]pktpacket to operate on
[in]secwhere to put it
[in]listthe rr_list to push
Returns
a boolean which is true when the rr was added

Definition at line 738 of file packet.c.

References ldns_pkt_safe_push_rr(), ldns_rr_list_rr(), and ldns_rr_list_rr_count().

◆ ldns_pkt_empty()

bool ldns_pkt_empty ( ldns_pkt p)

check if a packet is empty

Parameters
[in]ppacket
Returns
true: empty, false: not empty

Definition at line 430 of file packet.c.

References ldns_pkt_section_count(), and LDNS_SECTION_ANY.