view src/lib-dns/dns-lookup.h @ 14629:c93ca5e46a8a

Marked functions parameters that are allowed to be NULL. Some APIs were also changed. The non-obvious APIs where NULL parameter was changed to "" are master_service_init() and auth_master_user_list_init(). These checks can currently be enabled only on a patched clang: http://llvm.org/bugs/show_bug.cgi?id=6786
author Timo Sirainen <tss@iki.fi>
date Sun, 24 Jun 2012 00:52:57 +0300
parents f5aa38f0a9ac
children d3db2ba15d00
line wrap: on
line source

#ifndef DNS_LOOKUP_H
#define DNS_LOOKUP_H

struct dns_lookup;

struct dns_lookup_settings {
	const char *dns_client_socket_path;
	unsigned int timeout_msecs;
};

struct dns_lookup_result {
	/* all is ok if ret=0, otherwise it contains net_gethosterror()
	   compatible error code. error string is always set if ret != 0. */
	int ret;
	const char *error;

	/* how many milliseconds the lookup took. */
	unsigned int msecs;

	unsigned int ips_count;
	const struct ip_addr *ips;
};

typedef void dns_lookup_callback_t(const struct dns_lookup_result *result,
				   void *context);

/* Do asynchronous DNS lookup via dns-client UNIX socket. Returns 0 if lookup
   started, -1 if there was an error communicating with the UNIX socket.
   When failing with -1, the callback is called before returning from the
   function. */
int dns_lookup(const char *host, const struct dns_lookup_settings *set,
	       struct dns_lookup **lookup_r,
	       dns_lookup_callback_t *callback, void *context) ATTR_NULL(5);
#define dns_lookup(host, set, callback, context, lookup_r) \
	CONTEXT_CALLBACK2(dns_lookup, dns_lookup_callback_t, \
			  callback, const struct dns_lookup_result *, \
			  context, host, set, lookup_r)
/* Abort the DNS lookup without calling the callback. */
void dns_lookup_abort(struct dns_lookup **lookup);

#endif