Helper library to send DNS requests to DNS resolver. More...
Typedefs | |
typedef void(* | GNUNET_DNSSTUB_ResultCallback) (void *cls, const struct GNUNET_TUN_DnsHeader *dns, size_t dns_len) |
Function called with the result of a DNS resolution. More... | |
Functions | |
struct GNUNET_DNSSTUB_Context * | GNUNET_DNSSTUB_start (unsigned int num_sockets) |
Start a DNS stub resolver. More... | |
int | GNUNET_DNSSTUB_add_dns_ip (struct GNUNET_DNSSTUB_Context *ctx, const char *dns_ip) |
Add nameserver for use by the DNSSTUB. More... | |
int | GNUNET_DNSSTUB_add_dns_sa (struct GNUNET_DNSSTUB_Context *ctx, const struct sockaddr *sa) |
Add nameserver for use by the DNSSTUB. More... | |
void | GNUNET_DNSSTUB_set_retry (struct GNUNET_DNSSTUB_Context *ctx, struct GNUNET_TIME_Relative retry_freq) |
How long should we try requests before timing out? Only effective for requests issued after this call. More... | |
void | GNUNET_DNSSTUB_stop (struct GNUNET_DNSSTUB_Context *ctx) |
Cleanup DNSSTUB resolver. More... | |
struct GNUNET_DNSSTUB_RequestSocket * | GNUNET_DNSSTUB_resolve (struct GNUNET_DNSSTUB_Context *ctx, const void *request, size_t request_len, GNUNET_DNSSTUB_ResultCallback rc, void *rc_cls) |
Perform DNS resolution using our default IP from init. More... | |
void | GNUNET_DNSSTUB_resolve_cancel (struct GNUNET_DNSSTUB_RequestSocket *rs) |
Cancel DNS resolution. More... | |
Helper library to send DNS requests to DNS resolver.
typedef void(* GNUNET_DNSSTUB_ResultCallback) (void *cls, const struct GNUNET_TUN_DnsHeader *dns, size_t dns_len) |
Function called with the result of a DNS resolution.
Once this function is called, the resolution request is automatically cancelled / cleaned up. In particular, the function will only be called once.
cls | closure |
dns | dns response, NULL on hard error (i.e. timeout) |
dns_len | number of bytes in dns |
Definition at line 122 of file gnunet_dnsstub_lib.h.
struct GNUNET_DNSSTUB_Context * GNUNET_DNSSTUB_start | ( | unsigned int | num_sockets | ) |
Start a DNS stub resolver.
num_sockets | how many sockets should we open in parallel for DNS queries for this stub? |
Definition at line 586 of file dnsstub.c.
References ctx, DNS_RETRANSMIT_DELAY, GNUNET_break, GNUNET_new, GNUNET_new_array, and GNUNET_DNSSTUB_Context::num_sockets.
Referenced by advertise_dns_exit(), init_cb(), main(), recursive_gns2dns_resolution(), and run().
int GNUNET_DNSSTUB_add_dns_ip | ( | struct GNUNET_DNSSTUB_Context * | ctx, |
const char * | dns_ip | ||
) |
Add nameserver for use by the DNSSTUB.
We will use all provided nameservers for resolution (round-robin).
ctx | resolver context to modify |
dns_ip | target IP address to use (as string) |
Definition at line 613 of file dnsstub.c.
References ctx, dns_ip, ds, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_OK, and GNUNET_SYSERR.
Referenced by advertise_dns_exit(), init_cb(), main(), recursive_gns2dns_resolution(), and run().
int GNUNET_DNSSTUB_add_dns_sa | ( | struct GNUNET_DNSSTUB_Context * | ctx, |
const struct sockaddr * | sa | ||
) |
Add nameserver for use by the DNSSTUB.
We will use all provided nameservers for resolution (round-robin).
ctx | resolver context to modify |
sa | socket address of DNS resolver to use |
Definition at line 665 of file dnsstub.c.
References ctx, ds, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_free, GNUNET_memcpy, GNUNET_new, GNUNET_OK, and GNUNET_SYSERR.
Referenced by handle_gns2dns_ip(), and handle_gns2dns_result().
void GNUNET_DNSSTUB_set_retry | ( | struct GNUNET_DNSSTUB_Context * | ctx, |
struct GNUNET_TIME_Relative | retry_freq | ||
) |
void GNUNET_DNSSTUB_stop | ( | struct GNUNET_DNSSTUB_Context * | ctx | ) |
Cleanup DNSSTUB resolver.
ctx | stub resolver to clean up |
Definition at line 705 of file dnsstub.c.
References cleanup_rs(), ctx, ds, GNUNET_CONTAINER_DLL_remove, and GNUNET_free.
Referenced by cleanup(), cleanup_task(), do_shutdown(), GNS_resolver_lookup_cancel(), run(), and shutdown_task().
struct GNUNET_DNSSTUB_RequestSocket * GNUNET_DNSSTUB_resolve | ( | struct GNUNET_DNSSTUB_Context * | ctx, |
const void * | request, | ||
size_t | request_len, | ||
GNUNET_DNSSTUB_ResultCallback | rc, | ||
void * | rc_cls | ||
) |
Perform DNS resolution using our default IP from init.
ctx | stub resolver to use |
request | DNS request to transmit |
request_len | number of bytes in msg |
rc | function to call with result (once) |
rc_cls | closure for rc |
ctx | stub resolver to use |
request | DNS request to transmit |
request_len | number of bytes in msg |
rc | function to call with result |
rc_cls | closure for 'rc' |
Definition at line 526 of file dnsstub.c.
References ctx, GNUNET_DNSSTUB_RequestSocket::ds_pos, get_request_socket(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_memdup, GNUNET_SCHEDULER_add_now(), GNUNET_DNSSTUB_RequestSocket::rc, GNUNET_DNSSTUB_RequestSocket::rc_cls, request, GNUNET_DNSSTUB_RequestSocket::request, GNUNET_DNSSTUB_RequestSocket::request_len, GNUNET_DNSSTUB_RequestSocket::retry_task, and transmit_query().
Referenced by handle_dns_request(), handle_resolve_result(), next_phase(), process_queue(), recursive_dns_resolution(), resolve_and_cache(), result_processor(), and submit_req().
void GNUNET_DNSSTUB_resolve_cancel | ( | struct GNUNET_DNSSTUB_RequestSocket * | rs | ) |
Cancel DNS resolution.
rs | resolution to cancel |
Definition at line 562 of file dnsstub.c.
References GNUNET_SCHEDULER_cancel(), GNUNET_DNSSTUB_RequestSocket::rc, GNUNET_DNSSTUB_RequestSocket::read_task, and GNUNET_DNSSTUB_RequestSocket::retry_task.
Referenced by dns_result_parser(), dns_result_processor(), do_timeout(), free_active_lookup(), GNS_resolver_lookup_cancel(), handle_resolve_result(), and process_result().