Changeset View
Changeset View
Standalone View
Standalone View
contrib/ldns/ldns/packet.h
Show All 29 Lines | |||||
#define LDNS_RD 8 /* Recursion Desired - query flag */ | #define LDNS_RD 8 /* Recursion Desired - query flag */ | ||||
#define LDNS_CD 16 /* Checking Disabled - query flag */ | #define LDNS_CD 16 /* Checking Disabled - query flag */ | ||||
#define LDNS_RA 32 /* Recursion Available - server flag */ | #define LDNS_RA 32 /* Recursion Available - server flag */ | ||||
#define LDNS_AD 64 /* Authenticated Data - server flag */ | #define LDNS_AD 64 /* Authenticated Data - server flag */ | ||||
#include <ldns/error.h> | #include <ldns/error.h> | ||||
#include <ldns/common.h> | #include <ldns/common.h> | ||||
#include <ldns/rr.h> | #include <ldns/rr.h> | ||||
#include <ldns/edns.h> | |||||
#include <sys/time.h> | #include <sys/time.h> | ||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
extern "C" { | extern "C" { | ||||
#endif | #endif | ||||
/* opcodes for pkt's */ | /* opcodes for pkt's */ | ||||
enum ldns_enum_pkt_opcode { | enum ldns_enum_pkt_opcode { | ||||
▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | struct ldns_struct_pkt | ||||
/** Optional tsig rr */ | /** Optional tsig rr */ | ||||
ldns_rr *_tsig_rr; | ldns_rr *_tsig_rr; | ||||
/** EDNS0 available buffer size, see RFC2671 */ | /** EDNS0 available buffer size, see RFC2671 */ | ||||
uint16_t _edns_udp_size; | uint16_t _edns_udp_size; | ||||
/** EDNS0 Extended rcode */ | /** EDNS0 Extended rcode */ | ||||
uint8_t _edns_extended_rcode; | uint8_t _edns_extended_rcode; | ||||
/** EDNS Version */ | /** EDNS Version */ | ||||
uint8_t _edns_version; | uint8_t _edns_version; | ||||
/* OPT pseudo-RR presence flag */ | /* OPT pseudo-RR presence flag */ | ||||
uint8_t _edns_present; | uint8_t _edns_present; | ||||
/** Reserved EDNS data bits */ | /** Reserved EDNS data bits */ | ||||
uint16_t _edns_z; | uint16_t _edns_z; | ||||
/** Arbitrary EDNS rdata */ | /** Arbitrary EDNS rdata */ | ||||
ldns_rdf *_edns_data; | ldns_rdf *_edns_data; | ||||
/** Structed EDNS data */ | |||||
ldns_edns_option_list *_edns_list; | |||||
/** Question section */ | /** Question section */ | ||||
ldns_rr_list *_question; | ldns_rr_list *_question; | ||||
/** Answer section */ | /** Answer section */ | ||||
ldns_rr_list *_answer; | ldns_rr_list *_answer; | ||||
/** Authority section */ | /** Authority section */ | ||||
ldns_rr_list *_authority; | ldns_rr_list *_authority; | ||||
/** Additional section */ | /** Additional section */ | ||||
ldns_rr_list *_additional; | ldns_rr_list *_additional; | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | |||||
bool ldns_pkt_ad(const ldns_pkt *p); | bool ldns_pkt_ad(const ldns_pkt *p); | ||||
/** | /** | ||||
* Read the packet's code | * Read the packet's code | ||||
* \param[in] p the packet | * \param[in] p the packet | ||||
* \return the opcode | * \return the opcode | ||||
*/ | */ | ||||
ldns_pkt_opcode ldns_pkt_get_opcode(const ldns_pkt *p); | ldns_pkt_opcode ldns_pkt_get_opcode(const ldns_pkt *p); | ||||
/** | /** | ||||
* Return the packet's respons code | * Return the packet's response code | ||||
* \param[in] p the packet | * \param[in] p the packet | ||||
* \return the respons code | * \return the response code | ||||
*/ | */ | ||||
ldns_pkt_rcode ldns_pkt_get_rcode(const ldns_pkt *p); | ldns_pkt_rcode ldns_pkt_get_rcode(const ldns_pkt *p); | ||||
/** | /** | ||||
* Return the packet's qd count | * Return the packet's qd count | ||||
* \param[in] p the packet | * \param[in] p the packet | ||||
* \return the qd count | * \return the qd count | ||||
*/ | */ | ||||
uint16_t ldns_pkt_qdcount(const ldns_pkt *p); | uint16_t ldns_pkt_qdcount(const ldns_pkt *p); | ||||
▲ Show 20 Lines • Show All 212 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Set the packet's opcode | * Set the packet's opcode | ||||
* \param[in] p the packet | * \param[in] p the packet | ||||
* \param[in] c the opcode | * \param[in] c the opcode | ||||
*/ | */ | ||||
void ldns_pkt_set_opcode(ldns_pkt *p, ldns_pkt_opcode c); | void ldns_pkt_set_opcode(ldns_pkt *p, ldns_pkt_opcode c); | ||||
/** | /** | ||||
* Set the packet's respons code | * Set the packet's response code | ||||
* \param[in] p the packet | * \param[in] p the packet | ||||
* \param[in] c the rcode | * \param[in] c the rcode | ||||
*/ | */ | ||||
void ldns_pkt_set_rcode(ldns_pkt *p, uint8_t c); | void ldns_pkt_set_rcode(ldns_pkt *p, uint8_t c); | ||||
/** | /** | ||||
* Set the packet's qd count | * Set the packet's qd count | ||||
* \param[in] p the packet | * \param[in] p the packet | ||||
* \param[in] c the count | * \param[in] c the count | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
uint8_t ldns_pkt_edns_version(const ldns_pkt *packet); | uint8_t ldns_pkt_edns_version(const ldns_pkt *packet); | ||||
/** | /** | ||||
* return the packet's edns z value | * return the packet's edns z value | ||||
* \param[in] packet the packet | * \param[in] packet the packet | ||||
* \return the z value | * \return the z value | ||||
*/ | */ | ||||
uint16_t ldns_pkt_edns_z(const ldns_pkt *packet); | uint16_t ldns_pkt_edns_z(const ldns_pkt *packet); | ||||
/** | /** | ||||
* return the packet's edns data | * return the packet's EDNS data | ||||
* \param[in] packet the packet | * \param[in] packet the packet | ||||
* \return the data | * \return the data | ||||
*/ | */ | ||||
ldns_rdf *ldns_pkt_edns_data(const ldns_pkt *packet); | ldns_rdf *ldns_pkt_edns_data(const ldns_pkt *packet); | ||||
/** | /** | ||||
* return the packet's edns do bit | * return the packet's edns do bit | ||||
* \param[in] packet the packet | * \param[in] packet the packet | ||||
* \return the bit's value | * \return the bit's value | ||||
*/ | */ | ||||
bool ldns_pkt_edns_do(const ldns_pkt *packet); | bool ldns_pkt_edns_do(const ldns_pkt *packet); | ||||
/** | /** | ||||
* Set the packet's edns do bit | * Set the packet's edns do bit | ||||
* \param[in] packet the packet | * \param[in] packet the packet | ||||
* \param[in] value the bit's new value | * \param[in] value the bit's new value | ||||
*/ | */ | ||||
void ldns_pkt_set_edns_do(ldns_pkt *packet, bool value); | void ldns_pkt_set_edns_do(ldns_pkt *packet, bool value); | ||||
/** | /** | ||||
* return the packet's EDNS header bits that are unassigned. | |||||
*/ | |||||
uint16_t ldns_pkt_edns_unassigned(const ldns_pkt *packet); | |||||
/** | |||||
* Set the packet's EDNS header bits that are unassigned. | |||||
* \param[in] packet the packet | |||||
* \param[in] value the value | |||||
*/ | |||||
void ldns_pkt_set_edns_unassigned(ldns_pkt *packet, uint16_t value); | |||||
/** | |||||
* returns true if this packet needs and EDNS rr to be sent. | * returns true if this packet needs and EDNS rr to be sent. | ||||
* At the moment the only reason is an expected packet | * At the moment the only reason is an expected packet | ||||
* size larger than 512 bytes, but for instance dnssec would | * size larger than 512 bytes, but for instance dnssec would | ||||
* be a good reason too. | * be a good reason too. | ||||
* | * | ||||
* \param[in] packet the packet to check | * \param[in] packet the packet to check | ||||
* \return true if packet needs edns rr | * \return true if packet needs edns rr | ||||
*/ | */ | ||||
bool ldns_pkt_edns(const ldns_pkt *packet); | bool ldns_pkt_edns(const 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. | |||||
* | |||||
* \param[in] packet the packet which contains the EDNS data | |||||
* \return the list of EDNS options | |||||
*/ | |||||
ldns_edns_option_list* ldns_pkt_edns_get_option_list(ldns_pkt *packet); | |||||
/** | |||||
* Set the packet's edns udp size | * Set the packet's edns udp size | ||||
* \param[in] packet the packet | * \param[in] packet the packet | ||||
* \param[in] s the size | * \param[in] s the size | ||||
*/ | */ | ||||
void ldns_pkt_set_edns_udp_size(ldns_pkt *packet, uint16_t s); | void ldns_pkt_set_edns_udp_size(ldns_pkt *packet, uint16_t s); | ||||
/** | /** | ||||
* Set the packet's edns extended rcode | * Set the packet's edns extended rcode | ||||
* \param[in] packet the packet | * \param[in] packet the packet | ||||
* \param[in] c the code | * \param[in] c the code | ||||
*/ | */ | ||||
void ldns_pkt_set_edns_extended_rcode(ldns_pkt *packet, uint8_t c); | void ldns_pkt_set_edns_extended_rcode(ldns_pkt *packet, uint8_t c); | ||||
/** | /** | ||||
* Set the packet's edns version | * Set the packet's edns version | ||||
* \param[in] packet the packet | * \param[in] packet the packet | ||||
* \param[in] v the version | * \param[in] v the version | ||||
*/ | */ | ||||
void ldns_pkt_set_edns_version(ldns_pkt *packet, uint8_t v); | void ldns_pkt_set_edns_version(ldns_pkt *packet, uint8_t v); | ||||
/** | /** | ||||
* Set the packet's edns z value | * Set the packet's edns z value | ||||
* \param[in] packet the packet | * \param[in] packet the packet | ||||
* \param[in] z the value | * \param[in] z the value | ||||
*/ | */ | ||||
void ldns_pkt_set_edns_z(ldns_pkt *packet, uint16_t z); | void ldns_pkt_set_edns_z(ldns_pkt *packet, uint16_t z); | ||||
/** | /** | ||||
* Set the packet's edns data | * Set the packet's EDNS data | ||||
* \param[in] packet the packet | * \param[in] packet the packet | ||||
* \param[in] data the data | * \param[in] data the data | ||||
*/ | */ | ||||
void ldns_pkt_set_edns_data(ldns_pkt *packet, ldns_rdf *data); | void ldns_pkt_set_edns_data(ldns_pkt *packet, ldns_rdf *data); | ||||
/** | /** | ||||
* 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. | |||||
* \param[in] packet the packet | |||||
* \param[in] list the options list that will create the data | |||||
*/ | |||||
void ldns_pkt_set_edns_option_list(ldns_pkt *packet, ldns_edns_option_list *list); | |||||
/** | |||||
* allocates and initializes a ldns_pkt structure. | * allocates and initializes a ldns_pkt structure. | ||||
* \return pointer to the new packet | * \return pointer to the new packet | ||||
*/ | */ | ||||
ldns_pkt *ldns_pkt_new(void); | ldns_pkt *ldns_pkt_new(void); | ||||
/** | /** | ||||
* frees the packet structure and all data that it contains. | * frees the packet structure and all data that it contains. | ||||
* \param[in] packet The packet structure to free | * \param[in] packet The packet structure to free | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* directly set the question section | * directly set the question section | ||||
* \param[in] p packet to operate on | * \param[in] p packet to operate on | ||||
* \param[in] rr rrlist to set | * \param[in] rr rrlist to set | ||||
*/ | */ | ||||
void ldns_pkt_set_question(ldns_pkt *p, ldns_rr_list *rr); | void ldns_pkt_set_question(ldns_pkt *p, ldns_rr_list *rr); | ||||
/** | /** | ||||
* directly set the auhority section | * directly set the authority section | ||||
* \param[in] p packet to operate on | * \param[in] p packet to operate on | ||||
* \param[in] rr rrlist to set | * \param[in] rr rrlist to set | ||||
*/ | */ | ||||
void ldns_pkt_set_authority(ldns_pkt *p, ldns_rr_list *rr); | void ldns_pkt_set_authority(ldns_pkt *p, ldns_rr_list *rr); | ||||
/** | /** | ||||
* push an rr on a packet | * push an rr on a packet | ||||
* \param[in] packet packet to operate on | * \param[in] packet packet to operate on | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |