helper library to parse DNS packets. More...
Go to the source code of this file.
Functions | |
int | GNUNET_DNSPARSER_check_label (const char *label) |
Check if a label in UTF-8 format can be coded into valid IDNA. More... | |
int | GNUNET_DNSPARSER_check_name (const char *name) |
Check if a label in UTF-8 format can be coded into valid IDNA. More... | |
void | GNUNET_DNSPARSER_free_soa (struct GNUNET_DNSPARSER_SoaRecord *soa) |
Free SOA information record. More... | |
void | GNUNET_DNSPARSER_free_cert (struct GNUNET_DNSPARSER_CertRecord *cert) |
Free CERT information record. More... | |
void | GNUNET_DNSPARSER_free_srv (struct GNUNET_DNSPARSER_SrvRecord *srv) |
Free SRV information record. More... | |
void | GNUNET_DNSPARSER_free_uri (struct GNUNET_DNSPARSER_UriRecord *uri) |
Free URI information record. More... | |
void | GNUNET_DNSPARSER_free_mx (struct GNUNET_DNSPARSER_MxRecord *mx) |
Free MX information record. More... | |
void | GNUNET_DNSPARSER_free_record (struct GNUNET_DNSPARSER_Record *r) |
Free the given DNS record. More... | |
static char * | parse_name (const char *udp_payload, size_t udp_payload_length, size_t *off, unsigned int depth) |
Parse name inside of a DNS query or record. More... | |
char * | GNUNET_DNSPARSER_parse_name (const char *udp_payload, size_t udp_payload_length, size_t *off) |
Parse name inside of a DNS query or record. More... | |
int | GNUNET_DNSPARSER_parse_query (const char *udp_payload, size_t udp_payload_length, size_t *off, struct GNUNET_DNSPARSER_Query *q) |
Parse a DNS query entry. More... | |
struct GNUNET_DNSPARSER_SoaRecord * | GNUNET_DNSPARSER_parse_soa (const char *udp_payload, size_t udp_payload_length, size_t *off) |
Parse a DNS SOA record. More... | |
struct GNUNET_DNSPARSER_MxRecord * | GNUNET_DNSPARSER_parse_mx (const char *udp_payload, size_t udp_payload_length, size_t *off) |
Parse a DNS MX record. More... | |
struct GNUNET_DNSPARSER_SrvRecord * | GNUNET_DNSPARSER_parse_srv (const char *udp_payload, size_t udp_payload_length, size_t *off) |
Parse a DNS SRV record. More... | |
struct GNUNET_DNSPARSER_UriRecord * | GNUNET_DNSPARSER_parse_uri (const char *udp_payload, size_t udp_payload_length, size_t *off) |
Parse a DNS URI record. More... | |
struct GNUNET_DNSPARSER_CertRecord * | GNUNET_DNSPARSER_parse_cert (const char *udp_payload, size_t udp_payload_length, size_t *off) |
Parse a DNS CERT record. More... | |
int | GNUNET_DNSPARSER_parse_record (const char *udp_payload, size_t udp_payload_length, size_t *off, struct GNUNET_DNSPARSER_Record *r) |
Parse a DNS record entry. More... | |
struct GNUNET_DNSPARSER_Packet * | GNUNET_DNSPARSER_parse (const char *udp_payload, size_t udp_payload_length) |
Parse a UDP payload of a DNS packet in to a nice struct for further processing and manipulation. More... | |
struct GNUNET_DNSPARSER_Record * | GNUNET_DNSPARSER_duplicate_record (const struct GNUNET_DNSPARSER_Record *r) |
Duplicate (deep-copy) the given DNS record. More... | |
struct GNUNET_DNSPARSER_SoaRecord * | GNUNET_DNSPARSER_duplicate_soa_record (const struct GNUNET_DNSPARSER_SoaRecord *r) |
Duplicate (deep-copy) the given DNS record. More... | |
struct GNUNET_DNSPARSER_CertRecord * | GNUNET_DNSPARSER_duplicate_cert_record (const struct GNUNET_DNSPARSER_CertRecord *r) |
Duplicate (deep-copy) the given DNS record. More... | |
struct GNUNET_DNSPARSER_MxRecord * | GNUNET_DNSPARSER_duplicate_mx_record (const struct GNUNET_DNSPARSER_MxRecord *r) |
Duplicate (deep-copy) the given DNS record. More... | |
struct GNUNET_DNSPARSER_SrvRecord * | GNUNET_DNSPARSER_duplicate_srv_record (const struct GNUNET_DNSPARSER_SrvRecord *r) |
Duplicate (deep-copy) the given DNS record. More... | |
struct GNUNET_DNSPARSER_UriRecord * | GNUNET_DNSPARSER_duplicate_uri_record (const struct GNUNET_DNSPARSER_UriRecord *r) |
Duplicate (deep-copy) the given DNS record. More... | |
void | GNUNET_DNSPARSER_free_packet (struct GNUNET_DNSPARSER_Packet *p) |
Free memory taken by a packet. More... | |
int | GNUNET_DNSPARSER_builder_add_name (char *dst, size_t dst_len, size_t *off, const char *name) |
Add a DNS name to the UDP packet at the given location, converting the name to IDNA notation as necessary. More... | |
int | GNUNET_DNSPARSER_builder_add_query (char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_Query *query) |
Add a DNS query to the UDP packet at the given location. More... | |
int | GNUNET_DNSPARSER_builder_add_mx (char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_MxRecord *mx) |
Add an MX record to the UDP packet at the given location. More... | |
int | GNUNET_DNSPARSER_builder_add_cert (char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_CertRecord *cert) |
Add a CERT record to the UDP packet at the given location. More... | |
int | GNUNET_DNSPARSER_builder_add_soa (char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_SoaRecord *soa) |
Add an SOA record to the UDP packet at the given location. More... | |
int | GNUNET_DNSPARSER_builder_add_srv (char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_SrvRecord *srv) |
Add an SRV record to the UDP packet at the given location. More... | |
int | GNUNET_DNSPARSER_builder_add_uri (char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_UriRecord *uri) |
Add an URI record to the UDP packet at the given location. More... | |
static int | add_record (char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_Record *record) |
Add a DNS record to the UDP packet at the given location. More... | |
int | GNUNET_DNSPARSER_pack (const struct GNUNET_DNSPARSER_Packet *p, uint16_t max, char **buf, size_t *buf_length) |
Given a DNS packet p, generate the corresponding UDP payload. More... | |
char * | GNUNET_DNSPARSER_bin_to_hex (const void *data, size_t data_size) |
Convert a block of binary data to HEX. More... | |
size_t | GNUNET_DNSPARSER_hex_to_bin (const char *hex, void *data) |
Convert a HEX string to block of binary data. More... | |
helper library to parse DNS packets.
Definition in file dnsparser.c.
|
static |
Parse name inside of a DNS query or record.
udp_payload | entire UDP payload |
udp_payload_length | length of udp_payload |
off | pointer to the offset of the name to parse in the udp_payload (to be incremented by the size of the name) |
depth | current depth of our recursion (to prevent stack overflow) |
Definition at line 233 of file dnsparser.c.
References _, GNUNET_asprintf(), GNUNET_break_op, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_strdup, parse_name(), and ret.
Referenced by GNUNET_DNSPARSER_parse_name(), and parse_name().
|
static |
Add a DNS record to the UDP packet at the given location.
dst | where to write the query |
dst_len | number of bytes in dst |
off | pointer to offset where to write the query (increment by bytes used) must not be changed if there is an error |
record | record to write |
Definition at line 1286 of file dnsparser.c.
References GNUNET_TUN_DnsRecordLine::data_len, GNUNET_TUN_DnsRecordLine::dns_traffic_class, GNUNET_DNSPARSER_builder_add_cert(), GNUNET_DNSPARSER_builder_add_mx(), GNUNET_DNSPARSER_builder_add_name(), GNUNET_DNSPARSER_builder_add_soa(), GNUNET_DNSPARSER_builder_add_srv(), GNUNET_DNSPARSER_builder_add_uri(), GNUNET_DNSPARSER_TYPE_CERT, GNUNET_DNSPARSER_TYPE_CNAME, GNUNET_DNSPARSER_TYPE_MX, GNUNET_DNSPARSER_TYPE_NS, GNUNET_DNSPARSER_TYPE_PTR, GNUNET_DNSPARSER_TYPE_SOA, GNUNET_DNSPARSER_TYPE_SRV, GNUNET_DNSPARSER_TYPE_URI, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_TIME_absolute_get_remaining(), record(), GNUNET_TIME_Relative::rel_value_us, ret, start, GNUNET_TUN_DnsRecordLine::ttl, and GNUNET_TUN_DnsRecordLine::type.
Referenced by GNUNET_DNSPARSER_pack().