Helper library to parse DNS packets. More...
Data Structures | |
struct | GNUNET_DNSPARSER_Query |
A DNS query. More... | |
struct | GNUNET_DNSPARSER_MxRecord |
Information from MX records (RFC 1035). More... | |
struct | GNUNET_DNSPARSER_SrvRecord |
Information from SRV records (RFC 2782). More... | |
struct | GNUNET_DNSPARSER_UriRecord |
Information from URI records (RFC 7553). More... | |
struct | GNUNET_DNSPARSER_CertRecord |
Information from CERT records (RFC 4034). More... | |
struct | GNUNET_DNSPARSER_SoaRecord |
Information from SOA records (RFC 1035). More... | |
struct | GNUNET_DNSPARSER_CaaRecord |
Information from CAA records (RFC 6844). More... | |
struct | GNUNET_DNSPARSER_RawRecord |
Binary record information (unparsed). More... | |
struct | GNUNET_DNSPARSER_Record |
A DNS response record. More... | |
struct | GNUNET_DNSPARSER_Packet |
Easy-to-process, parsed version of a DNS packet. More... | |
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 hostname in UTF-8 format can be coded into valid IDNA. 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... | |
void | GNUNET_DNSPARSER_free_packet (struct GNUNET_DNSPARSER_Packet *p) |
Free memory taken by a packet. 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... | |
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_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_cert (char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_CertRecord *cert) |
Add CERT 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... | |
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... | |
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_CertRecord * | GNUNET_DNSPARSER_parse_cert (const char *udp_payload, size_t udp_payload_length, size_t *off) |
Parse a DNS CERT 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_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_record (struct GNUNET_DNSPARSER_Record *r) |
Free the given DNS record. More... | |
void | GNUNET_DNSPARSER_free_mx (struct GNUNET_DNSPARSER_MxRecord *mx) |
Free MX 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_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... | |
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.
#define GNUNET_DNSPARSER_MAX_LABEL_LENGTH 63 |
Maximum length of a label in DNS.
Definition at line 46 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_MAX_NAME_LENGTH 253 |
Maximum length of a name in DNS.
Definition at line 51 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_ANY 0 |
A few common DNS types.
Definition at line 57 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_A 1 |
Definition at line 58 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_NS 2 |
Definition at line 59 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_CNAME 5 |
Definition at line 60 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_SOA 6 |
Definition at line 61 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_PTR 12 |
Definition at line 62 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_MX 15 |
Definition at line 63 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_TXT 16 |
Definition at line 64 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_RP 17 |
Definition at line 65 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_AFSDB 18 |
Definition at line 66 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_SIG 24 |
Definition at line 67 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_KEY 25 |
Definition at line 68 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_AAAA 28 |
Definition at line 69 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_LOC 29 |
Definition at line 70 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_SRV 33 |
Definition at line 71 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_NAPTR 35 |
Definition at line 72 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_KX 36 |
Definition at line 73 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_CERT 37 |
Definition at line 74 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_DNAME 39 |
Definition at line 75 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_APL 42 |
Definition at line 76 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_DS 43 |
Definition at line 77 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_SSHFP 44 |
Definition at line 78 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_IPSECKEY 45 |
Definition at line 79 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_RRSIG 46 |
Definition at line 80 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_NSEC 47 |
Definition at line 81 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_DNSKEY 48 |
Definition at line 82 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_DHCID 49 |
Definition at line 83 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_NSEC3 50 |
Definition at line 84 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_NSEC3PARAM 51 |
Definition at line 85 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_TLSA 52 |
Definition at line 86 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_SMIMEA 53 |
Definition at line 87 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_HIP 55 |
Definition at line 88 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_CDS 59 |
Definition at line 89 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_CDNSKEY 60 |
Definition at line 90 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_OPENPGPKEY 61 |
Definition at line 91 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_TKEY 249 |
Definition at line 92 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_TSIG 250 |
Definition at line 93 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_ALL 255 |
Definition at line 94 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_URI 256 |
Definition at line 95 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_CAA 257 |
Definition at line 96 of file gnunet_dnsparser_lib.h.
#define GNUNET_DNSPARSER_TYPE_TA 32768 |
Definition at line 97 of file gnunet_dnsparser_lib.h.
DNS CERT types as defined in RFC 4398.
Definition at line 211 of file gnunet_dnsparser_lib.h.
DNSCERT algorithms as defined in http://www.iana.org/assignments/ dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml, under dns-sec-alg-numbers-1.
Definition at line 264 of file gnunet_dnsparser_lib.h.
int GNUNET_DNSPARSER_check_label | ( | const char * | label | ) |
Check if a label in UTF-8 format can be coded into valid IDNA.
This can fail if the ASCII-conversion becomes longer than 63 characters.
label | label to check (UTF-8 string) |
Definition at line 53 of file dnsparser.c.
References GNUNET_OK, and GNUNET_SYSERR.
Referenced by GNUNET_DNSPARSER_check_name().
int GNUNET_DNSPARSER_check_name | ( | const char * | name | ) |
Check if a hostname in UTF-8 format can be coded into valid IDNA.
This can fail if a label becomes longer than 63 characters or if the entire name exceeds 253 characters.
name | name to check (UTF-8 string) |
Check if a hostname in UTF-8 format can be coded into valid IDNA.
This can fail if the ASCII-conversion becomes longer than 253 characters.
name | name to check (UTF-8 string) |
Definition at line 79 of file dnsparser.c.
References GNUNET_DNSPARSER_check_label(), GNUNET_free, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, and name.
Referenced by queue(), and run().
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.
udp_payload | wire-format of the DNS packet |
udp_payload_length | number of bytes in udp_payload |
Definition at line 729 of file dnsparser.c.
References GNUNET_TUN_DnsHeader::additional_rcount, GNUNET_TUN_DnsHeader::answer_rcount, GNUNET_TUN_DnsHeader::authority_rcount, GNUNET_TUN_DnsHeader::flags, GNUNET_break_op, GNUNET_DNSPARSER_free_packet(), GNUNET_DNSPARSER_parse_query(), GNUNET_DNSPARSER_parse_record(), GNUNET_new, GNUNET_new_array, GNUNET_OK, GNUNET_TUN_DnsHeader::id, p, and GNUNET_TUN_DnsHeader::query_count.
Referenced by display_request(), dns_post_request_handler(), dns_result_parser(), dns_result_processor(), handle_dns_request(), handle_request(), handle_resolve_result(), modify_request(), and process_result().
void GNUNET_DNSPARSER_free_packet | ( | struct GNUNET_DNSPARSER_Packet * | p | ) |
Free memory taken by a packet.
p | packet to free |
Definition at line 950 of file dnsparser.c.
References GNUNET_DNSPARSER_free_record(), GNUNET_free, and p.
Referenced by display_request(), dns_post_request_handler(), dns_result_parser(), do_timeout(), finish_request(), GNS_interceptor_done(), GNUNET_DNSPARSER_parse(), handle_dns_request(), handle_request(), handle_resolve_result(), modify_request(), process_result(), recursive_dns_resolution(), reply_to_dns(), result_processor(), send_response(), and vpn_allocation_callback().
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.
Note that we do not attempt to pack the strings with pointers as this would complicate the code and this is about being simple and secure, not fast, fancy and broken like bind.
p | packet to pack |
max | maximum allowed size for the resulting UDP payload |
buf | set to a buffer with the packed message |
buf_length | set to the length of buf |
Definition at line 1400 of file dnsparser.c.
References add_record(), GNUNET_TUN_DnsHeader::additional_rcount, GNUNET_TUN_DnsHeader::answer_rcount, GNUNET_TUN_DnsHeader::authority_rcount, GNUNET_TUN_DnsHeader::flags, GNUNET_DNSPARSER_builder_add_query(), GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_TUN_DnsHeader::id, max, GNUNET_TUN_DnsFlags::message_truncated, p, GNUNET_TUN_DnsHeader::query_count, and ret.
Referenced by build_dns_query(), finish_request(), modify_request(), pack(), queue(), recursive_dns_resolution(), reply_to_dns(), and send_response().
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.
dst | where to write the name (UDP packet) |
dst_len | number of bytes in dst |
off | pointer to offset where to write the name (increment by bytes used) must not be changed if there is an error |
name | name to write |
Definition at line 985 of file dnsparser.c.
References _, GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, idna_name, name, SIZE_MAX, and start.
Referenced by add_record(), check_for_glue(), dns_result_parser(), dns_string_to_value(), gns_string_to_value(), GNUNET_DNSPARSER_builder_add_mx(), GNUNET_DNSPARSER_builder_add_query(), GNUNET_DNSPARSER_builder_add_soa(), GNUNET_DNSPARSER_builder_add_srv(), handle_gns_resolution_result(), and process_record().
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.
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 |
query | query to write |
Definition at line 1063 of file dnsparser.c.
References GNUNET_DNSPARSER_Query::dns_traffic_class, GNUNET_TUN_DnsQueryLine::dns_traffic_class, GNUNET_assert, GNUNET_DNSPARSER_builder_add_name(), GNUNET_memcpy, GNUNET_OK, GNUNET_DNSPARSER_Query::name, ret, GNUNET_DNSPARSER_Query::type, and GNUNET_TUN_DnsQueryLine::type.
Referenced by GNUNET_DNSPARSER_pack().
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.
dst | where to write the mx record |
dst_len | number of bytes in dst |
off | pointer to offset where to write the mx information (increment by bytes used); can also change if there was an error |
mx | mx information to write |
Definition at line 1099 of file dnsparser.c.
References GNUNET_assert, GNUNET_DNSPARSER_builder_add_name(), GNUNET_memcpy, GNUNET_NO, GNUNET_DNSPARSER_MxRecord::mxhost, GNUNET_DNSPARSER_MxRecord::preference, and SIZE_MAX.
Referenced by add_record(), dns_result_parser(), dns_string_to_value(), handle_gns_resolution_result(), and process_record().
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.
dst | where to write the SOA record |
dst_len | number of bytes in dst |
off | pointer to offset where to write the SOA information (increment by bytes used) can also change if there was an error |
soa | SOA information to write |
Definition at line 1177 of file dnsparser.c.
References GNUNET_DNSPARSER_SoaRecord::expire, GNUNET_TUN_DnsSoaRecord::expire, GNUNET_DNSPARSER_builder_add_name(), GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_TUN_DnsSoaRecord::minimum, GNUNET_DNSPARSER_SoaRecord::minimum_ttl, GNUNET_DNSPARSER_SoaRecord::mname, GNUNET_DNSPARSER_SoaRecord::refresh, GNUNET_TUN_DnsSoaRecord::refresh, ret, GNUNET_DNSPARSER_SoaRecord::retry, GNUNET_TUN_DnsSoaRecord::retry, GNUNET_DNSPARSER_SoaRecord::rname, GNUNET_DNSPARSER_SoaRecord::serial, and GNUNET_TUN_DnsSoaRecord::serial.
Referenced by add_record(), dns_result_parser(), dns_string_to_value(), handle_gns_resolution_result(), and process_record().
int GNUNET_DNSPARSER_builder_add_cert | ( | char * | dst, |
size_t | dst_len, | ||
size_t * | off, | ||
const struct GNUNET_DNSPARSER_CertRecord * | cert | ||
) |
Add CERT record to the UDP packet at the given location.
dst | where to write the CERT record |
dst_len | number of bytes in dst |
off | pointer to offset where to write the CERT information (increment by bytes used) can also change if there was an error |
cert | CERT information to write |
Add CERT record to the UDP packet at the given location.
dst | where to write the CERT record |
dst_len | number of bytes in dst |
off | pointer to offset where to write the CERT information (increment by bytes used); can also change if there was an error |
cert | CERT information to write |
Definition at line 1129 of file dnsparser.c.
References GNUNET_DNSPARSER_CertRecord::algorithm, GNUNET_TUN_DnsCertRecord::algorithm, GNUNET_DNSPARSER_CertRecord::cert_tag, GNUNET_TUN_DnsCertRecord::cert_tag, GNUNET_DNSPARSER_CertRecord::cert_type, GNUNET_TUN_DnsCertRecord::cert_type, GNUNET_DNSPARSER_CertRecord::certificate_data, GNUNET_DNSPARSER_CertRecord::certificate_size, GNUNET_assert, GNUNET_break, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, and SIZE_MAX.
Referenced by add_record(), dns_string_to_value(), and process_record().
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.
dst | where to write the SRV record |
dst_len | number of bytes in dst |
off | pointer to offset where to write the SRV information (increment by bytes used) can also change if there was an error |
srv | SRV information to write |
Definition at line 1218 of file dnsparser.c.
References GNUNET_assert, GNUNET_DNSPARSER_builder_add_name(), GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_DNSPARSER_SrvRecord::port, GNUNET_TUN_DnsSrvRecord::port, GNUNET_TUN_DnsSrvRecord::prio, GNUNET_DNSPARSER_SrvRecord::priority, ret, SIZE_MAX, GNUNET_DNSPARSER_SrvRecord::target, GNUNET_DNSPARSER_SrvRecord::weight, and GNUNET_TUN_DnsSrvRecord::weight.
Referenced by add_record(), dns_result_parser(), dns_string_to_value(), handle_gns_resolution_result(), and process_record().
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.
dst | where to write the URI record |
dst_len | number of bytes in dst |
off | pointer to offset where to write the URI information (increment by bytes used) can also change if there was an error |
uri | URI information to write |
Definition at line 1255 of file dnsparser.c.
References GNUNET_assert, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_snprintf(), GNUNET_TUN_DnsUriRecord::prio, SIZE_MAX, uri, and GNUNET_TUN_DnsUriRecord::weight.
Referenced by add_record(), dns_result_parser(), dns_string_to_value(), handle_gns_resolution_result(), and process_record().
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.
udp_payload | entire UDP payload |
udp_payload_length | length of udp_payload |
off | pointer to the offset of the record to parse in the udp_payload (to be incremented by the size of the record) |
r | where to write the record information |
Definition at line 622 of file dnsparser.c.
References GNUNET_DNSPARSER_RawRecord::data, GNUNET_DNSPARSER_Record::data, GNUNET_DNSPARSER_RawRecord::data_len, GNUNET_TUN_DnsRecordLine::data_len, GNUNET_DNSPARSER_Record::dns_traffic_class, GNUNET_TUN_DnsRecordLine::dns_traffic_class, GNUNET_DNSPARSER_Record::expiration_time, GNUNET_break_op, GNUNET_DNSPARSER_parse_mx(), GNUNET_DNSPARSER_parse_name(), GNUNET_DNSPARSER_parse_soa(), GNUNET_DNSPARSER_parse_srv(), GNUNET_DNSPARSER_parse_uri(), GNUNET_DNSPARSER_TYPE_CNAME, GNUNET_DNSPARSER_TYPE_DNAME, 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_malloc, GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_SECONDS, GNUNET_DNSPARSER_Record::hostname, GNUNET_DNSPARSER_Record::mx, name, GNUNET_DNSPARSER_Record::name, GNUNET_DNSPARSER_Record::raw, GNUNET_DNSPARSER_Record::soa, GNUNET_DNSPARSER_Record::srv, GNUNET_TUN_DnsRecordLine::ttl, GNUNET_DNSPARSER_Record::type, GNUNET_TUN_DnsRecordLine::type, and GNUNET_DNSPARSER_Record::uri.
Referenced by GNUNET_DNSPARSER_parse().
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.
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) |
Definition at line 353 of file dnsparser.c.
References parse_name().
Referenced by dns_value_to_string(), gns_value_to_string(), GNUNET_DNSPARSER_parse_mx(), GNUNET_DNSPARSER_parse_query(), GNUNET_DNSPARSER_parse_record(), GNUNET_DNSPARSER_parse_soa(), GNUNET_DNSPARSER_parse_srv(), handle_gns_resolution_result(), recursive_cname_resolution(), recursive_gns2dns_resolution(), and reply_to_dns().
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.
udp_payload | entire UDP payload |
udp_payload_length | length of udp_payload |
off | pointer to the offset of the query to parse in the udp_payload (to be incremented by the size of the query) |
q | where to write the query information |
Definition at line 372 of file dnsparser.c.
References GNUNET_TUN_DnsQueryLine::dns_traffic_class, GNUNET_break_op, GNUNET_DNSPARSER_parse_name(), GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, name, q, and GNUNET_TUN_DnsQueryLine::type.
Referenced by GNUNET_DNSPARSER_parse().
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.
udp_payload | reference to UDP packet |
udp_payload_length | length of udp_payload |
off | pointer to the offset of the query to parse in the SOA record (to be incremented by the size of the record), unchanged on error |
Definition at line 410 of file dnsparser.c.
References GNUNET_DNSPARSER_SoaRecord::expire, GNUNET_TUN_DnsSoaRecord::expire, GNUNET_break_op, GNUNET_DNSPARSER_free_soa(), GNUNET_DNSPARSER_parse_name(), GNUNET_memcpy, GNUNET_new, GNUNET_TUN_DnsSoaRecord::minimum, GNUNET_DNSPARSER_SoaRecord::minimum_ttl, GNUNET_DNSPARSER_SoaRecord::mname, GNUNET_DNSPARSER_SoaRecord::refresh, GNUNET_TUN_DnsSoaRecord::refresh, GNUNET_DNSPARSER_SoaRecord::retry, GNUNET_TUN_DnsSoaRecord::retry, GNUNET_DNSPARSER_SoaRecord::rname, GNUNET_DNSPARSER_SoaRecord::serial, and GNUNET_TUN_DnsSoaRecord::serial.
Referenced by dns_value_to_string(), GNUNET_DNSPARSER_parse_record(), handle_gns_resolution_result(), and reply_to_dns().
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.
udp_payload | reference to UDP packet |
udp_payload_length | length of udp_payload |
off | pointer to the offset of the query to parse in the CERT record (to be incremented by the size of the record), unchanged on error |
Definition at line 581 of file dnsparser.c.
References GNUNET_DNSPARSER_CertRecord::algorithm, GNUNET_TUN_DnsCertRecord::algorithm, GNUNET_DNSPARSER_CertRecord::cert_tag, GNUNET_TUN_DnsCertRecord::cert_tag, GNUNET_DNSPARSER_CertRecord::cert_type, GNUNET_TUN_DnsCertRecord::cert_type, GNUNET_DNSPARSER_CertRecord::certificate_data, GNUNET_DNSPARSER_CertRecord::certificate_size, GNUNET_break_op, GNUNET_malloc, GNUNET_memcpy, and GNUNET_new.
Referenced by dns_value_to_string().
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.
udp_payload | reference to UDP packet |
udp_payload_length | length of udp_payload |
off | pointer to the offset of the query to parse in the MX record (to be incremented by the size of the record), unchanged on error |
Definition at line 455 of file dnsparser.c.
References GNUNET_break_op, GNUNET_DNSPARSER_free_mx(), GNUNET_DNSPARSER_parse_name(), GNUNET_memcpy, GNUNET_new, GNUNET_DNSPARSER_MxRecord::mxhost, and GNUNET_DNSPARSER_MxRecord::preference.
Referenced by dns_value_to_string(), GNUNET_DNSPARSER_parse_record(), handle_gns_resolution_result(), and reply_to_dns().
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.
udp_payload | reference to UDP packet |
udp_payload_length | length of udp_payload |
off | pointer to the offset of the query to parse in the SRV record (to be incremented by the size of the record), unchanged on error |
Definition at line 496 of file dnsparser.c.
References GNUNET_DNSPARSER_free_srv(), GNUNET_DNSPARSER_parse_name(), GNUNET_memcpy, GNUNET_new, GNUNET_DNSPARSER_SrvRecord::port, GNUNET_TUN_DnsSrvRecord::port, GNUNET_TUN_DnsSrvRecord::prio, GNUNET_DNSPARSER_SrvRecord::priority, GNUNET_DNSPARSER_SrvRecord::target, GNUNET_DNSPARSER_SrvRecord::weight, and GNUNET_TUN_DnsSrvRecord::weight.
Referenced by dns_value_to_string(), GNUNET_DNSPARSER_parse_record(), and handle_gns_resolution_result().
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.
udp_payload | reference to UDP packet |
udp_payload_length | length of udp_payload |
off | pointer to the offset of the query to parse in the URI record (to be incremented by the size of the record), unchanged on error |
Definition at line 537 of file dnsparser.c.
References GNUNET_asprintf(), GNUNET_DNSPARSER_free_uri(), GNUNET_memcpy, GNUNET_new, GNUNET_TUN_DnsUriRecord::prio, uri, and GNUNET_TUN_DnsUriRecord::weight.
Referenced by dns_value_to_string(), GNUNET_DNSPARSER_parse_record(), handle_gns_resolution_result(), and reply_to_dns().
struct GNUNET_DNSPARSER_Record * GNUNET_DNSPARSER_duplicate_record | ( | const struct GNUNET_DNSPARSER_Record * | r | ) |
Duplicate (deep-copy) the given DNS record.
r | the record |
Definition at line 810 of file dnsparser.c.
References GNUNET_DNSPARSER_Record::cert, GNUNET_DNSPARSER_RawRecord::data, GNUNET_DNSPARSER_Record::data, GNUNET_DNSPARSER_RawRecord::data_len, GNUNET_DNSPARSER_duplicate_cert_record(), GNUNET_DNSPARSER_duplicate_mx_record(), GNUNET_DNSPARSER_duplicate_soa_record(), GNUNET_DNSPARSER_duplicate_srv_record(), GNUNET_DNSPARSER_duplicate_uri_record(), 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_memdup, GNUNET_strdup, GNUNET_DNSPARSER_Record::hostname, GNUNET_DNSPARSER_Record::mx, GNUNET_DNSPARSER_Record::name, GNUNET_DNSPARSER_Record::raw, GNUNET_DNSPARSER_Record::soa, GNUNET_DNSPARSER_Record::srv, GNUNET_DNSPARSER_Record::type, and GNUNET_DNSPARSER_Record::uri.
Referenced by cache_answers().
struct GNUNET_DNSPARSER_SoaRecord * GNUNET_DNSPARSER_duplicate_soa_record | ( | const struct GNUNET_DNSPARSER_SoaRecord * | r | ) |
Duplicate (deep-copy) the given DNS record.
r | the record |
Definition at line 865 of file dnsparser.c.
References GNUNET_memdup, GNUNET_strdup, GNUNET_DNSPARSER_SoaRecord::mname, and GNUNET_DNSPARSER_SoaRecord::rname.
Referenced by GNUNET_DNSPARSER_duplicate_record().
struct GNUNET_DNSPARSER_CertRecord * GNUNET_DNSPARSER_duplicate_cert_record | ( | const struct GNUNET_DNSPARSER_CertRecord * | r | ) |
Duplicate (deep-copy) the given DNS record.
r | the record |
Definition at line 883 of file dnsparser.c.
References GNUNET_DNSPARSER_CertRecord::certificate_data, GNUNET_DNSPARSER_CertRecord::certificate_size, and GNUNET_memdup.
Referenced by GNUNET_DNSPARSER_duplicate_record().
struct GNUNET_DNSPARSER_MxRecord * GNUNET_DNSPARSER_duplicate_mx_record | ( | const struct GNUNET_DNSPARSER_MxRecord * | r | ) |
Duplicate (deep-copy) the given DNS record.
r | the record |
Definition at line 901 of file dnsparser.c.
References GNUNET_memdup, GNUNET_strdup, and GNUNET_DNSPARSER_MxRecord::mxhost.
Referenced by GNUNET_DNSPARSER_duplicate_record().
struct GNUNET_DNSPARSER_SrvRecord * GNUNET_DNSPARSER_duplicate_srv_record | ( | const struct GNUNET_DNSPARSER_SrvRecord * | r | ) |
Duplicate (deep-copy) the given DNS record.
r | the record |
Definition at line 917 of file dnsparser.c.
References GNUNET_memdup, GNUNET_strdup, and GNUNET_DNSPARSER_SrvRecord::target.
Referenced by GNUNET_DNSPARSER_duplicate_record().
struct GNUNET_DNSPARSER_UriRecord * GNUNET_DNSPARSER_duplicate_uri_record | ( | const struct GNUNET_DNSPARSER_UriRecord * | r | ) |
Duplicate (deep-copy) the given DNS record.
r | the record |
Definition at line 934 of file dnsparser.c.
References GNUNET_memdup, GNUNET_strdup, and GNUNET_DNSPARSER_UriRecord::target.
Referenced by GNUNET_DNSPARSER_duplicate_record().
void GNUNET_DNSPARSER_free_record | ( | struct GNUNET_DNSPARSER_Record * | r | ) |
Free the given DNS record.
r | record to free |
Definition at line 184 of file dnsparser.c.
References GNUNET_DNSPARSER_Record::cert, GNUNET_DNSPARSER_RawRecord::data, GNUNET_DNSPARSER_Record::data, GNUNET_DNSPARSER_free_cert(), GNUNET_DNSPARSER_free_mx(), GNUNET_DNSPARSER_free_soa(), GNUNET_DNSPARSER_free_srv(), GNUNET_DNSPARSER_free_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_free, GNUNET_DNSPARSER_Record::hostname, GNUNET_DNSPARSER_Record::mx, GNUNET_DNSPARSER_Record::name, GNUNET_DNSPARSER_Record::raw, GNUNET_DNSPARSER_Record::soa, GNUNET_DNSPARSER_Record::srv, GNUNET_DNSPARSER_Record::type, and GNUNET_DNSPARSER_Record::uri.
Referenced by free_cache_entry(), free_hosts_entry(), GNUNET_DNSPARSER_free_packet(), and remove_expired().
void GNUNET_DNSPARSER_free_mx | ( | struct GNUNET_DNSPARSER_MxRecord * | mx | ) |
Free MX information record.
mx | record to free |
Definition at line 169 of file dnsparser.c.
References GNUNET_free, and GNUNET_DNSPARSER_MxRecord::mxhost.
Referenced by dns_value_to_string(), GNUNET_DNSPARSER_free_record(), GNUNET_DNSPARSER_parse_mx(), and handle_gns_resolution_result().
void GNUNET_DNSPARSER_free_srv | ( | struct GNUNET_DNSPARSER_SrvRecord * | srv | ) |
Free SRV information record.
srv | record to free |
Definition at line 139 of file dnsparser.c.
References GNUNET_free, and GNUNET_DNSPARSER_SrvRecord::target.
Referenced by dns_value_to_string(), GNUNET_DNSPARSER_free_record(), GNUNET_DNSPARSER_parse_srv(), and handle_gns_resolution_result().
void GNUNET_DNSPARSER_free_uri | ( | struct GNUNET_DNSPARSER_UriRecord * | uri | ) |
Free URI information record.
uri | record to free |
Definition at line 154 of file dnsparser.c.
References GNUNET_free, and uri.
Referenced by dns_value_to_string(), GNUNET_DNSPARSER_free_record(), GNUNET_DNSPARSER_parse_uri(), and handle_gns_resolution_result().
void GNUNET_DNSPARSER_free_soa | ( | struct GNUNET_DNSPARSER_SoaRecord * | soa | ) |
Free SOA information record.
soa | record to free |
Definition at line 108 of file dnsparser.c.
References GNUNET_free, GNUNET_DNSPARSER_SoaRecord::mname, and GNUNET_DNSPARSER_SoaRecord::rname.
Referenced by dns_value_to_string(), GNUNET_DNSPARSER_free_record(), GNUNET_DNSPARSER_parse_soa(), and handle_gns_resolution_result().
void GNUNET_DNSPARSER_free_cert | ( | struct GNUNET_DNSPARSER_CertRecord * | cert | ) |
Free CERT information record.
cert | record to free |
Definition at line 124 of file dnsparser.c.
References GNUNET_DNSPARSER_CertRecord::certificate_data, and GNUNET_free.
Referenced by dns_value_to_string(), and GNUNET_DNSPARSER_free_record().
char * GNUNET_DNSPARSER_bin_to_hex | ( | const void * | data, |
size_t | data_size | ||
) |
Convert a block of binary data to HEX.
data | binary data to convert |
data_size | number of bytes in data |
Definition at line 1497 of file dnsparser.c.
References data, data_size, GNUNET_malloc, and ret.
Referenced by dns_value_to_string().
size_t GNUNET_DNSPARSER_hex_to_bin | ( | const char * | hex, |
void * | data | ||
) |
Convert a HEX string to block of binary data.
hex | HEX string to convert (may contain mixed case) |
data | where to write result, must be at least strlen(hex)/2 bytes long |
Definition at line 1520 of file dnsparser.c.
References data, data_size, and h.
Referenced by dns_string_to_value().