asyncns.h
Go to the documentation of this file.
#ifndef fooasyncnshfoo
#define fooasyncnshfoo
/***
This file is part of libasyncns.
Copyright 2005-2008 Lennart Poettering
libasyncns is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 2.1 of the
License, or (at your option) any later version.
libasyncns is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with libasyncns. If not, see
<http://www.gnu.org/licenses/>.
***/
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct asyncns asyncns_t;
typedef struct asyncns_query asyncns_query_t;
asyncns_t* asyncns_new(unsigned n_proc);
void asyncns_free(asyncns_t *asyncns);
int asyncns_fd(asyncns_t *asyncns);
int asyncns_wait(asyncns_t *asyncns, int block);
asyncns_query_t* asyncns_getaddrinfo(asyncns_t *asyncns, const char *node, const char *service, const struct addrinfo *hints);
int asyncns_getaddrinfo_done(asyncns_t *asyncns, asyncns_query_t* q, struct addrinfo **ret_res);
asyncns_query_t* asyncns_getnameinfo(asyncns_t *asyncns, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv);
int asyncns_getnameinfo_done(asyncns_t *asyncns, asyncns_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen);
asyncns_query_t* asyncns_res_query(asyncns_t *asyncns, const char *dname, int class, int type);
asyncns_query_t* asyncns_res_search(asyncns_t *asyncns, const char *dname, int class, int type);
int asyncns_res_done(asyncns_t *asyncns, asyncns_query_t* q, unsigned char **answer);
asyncns_query_t* asyncns_getnext(asyncns_t *asyncns);
int asyncns_getnqueries(asyncns_t *asyncns);
void asyncns_cancel(asyncns_t *asyncns, asyncns_query_t* q);
void asyncns_freeaddrinfo(struct addrinfo *ai);
void asyncns_freeanswer(unsigned char *answer);
int asyncns_isdone(asyncns_t *asyncns, asyncns_query_t*q);
void asyncns_setuserdata(asyncns_t *asyncns, asyncns_query_t *q, void *userdata);
void* asyncns_getuserdata(asyncns_t *asyncns, asyncns_query_t *q);
#ifdef __cplusplus
}
#endif
#endif
asyncns_free
void asyncns_free(asyncns_t *asyncns)
Free a libasyncns session.
asyncns_t
struct asyncns asyncns_t
An opaque libasyncns session structure.
Definition asyncns.h:51
asyncns_res_query
asyncns_query_t * asyncns_res_query(asyncns_t *asyncns, const char *dname, int class, int type)
Issue a resolver query on the specified session.
asyncns_isdone
int asyncns_isdone(asyncns_t *asyncns, asyncns_query_t *q)
Returns non-zero when the query operation specified by q has been completed.
asyncns_wait
int asyncns_wait(asyncns_t *asyncns, int block)
Process pending responses.
asyncns_freeanswer
void asyncns_freeanswer(unsigned char *answer)
Free the answer data as returned by asyncns_res_done().
asyncns_getaddrinfo
asyncns_query_t * asyncns_getaddrinfo(asyncns_t *asyncns, const char *node, const char *service, const struct addrinfo *hints)
Issue a name to address query on the specified session.
asyncns_freeaddrinfo
void asyncns_freeaddrinfo(struct addrinfo *ai)
Free the addrinfo structure as returned by asyncns_getaddrinfo_done().
asyncns_getnext
asyncns_query_t * asyncns_getnext(asyncns_t *asyncns)
Return the next completed query object.
asyncns_getnameinfo
asyncns_query_t * asyncns_getnameinfo(asyncns_t *asyncns, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv)
Issue an address to name query on the specified session.
asyncns_query_t
struct asyncns_query asyncns_query_t
An opaque libasyncns query structure.
Definition asyncns.h:54
asyncns_getnameinfo_done
int asyncns_getnameinfo_done(asyncns_t *asyncns, asyncns_query_t *q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen)
Retrieve the results of a preceding asyncns_getnameinfo() call.
asyncns_getaddrinfo_done
int asyncns_getaddrinfo_done(asyncns_t *asyncns, asyncns_query_t *q, struct addrinfo **ret_res)
Retrieve the results of a preceding asyncns_getaddrinfo() call.
asyncns_fd
int asyncns_fd(asyncns_t *asyncns)
Return the UNIX file descriptor to select() for readability on.
asyncns_new
asyncns_t * asyncns_new(unsigned n_proc)
Allocate a new libasyncns session with n_proc worker processes/threads.
asyncns_setuserdata
void asyncns_setuserdata(asyncns_t *asyncns, asyncns_query_t *q, void *userdata)
Assign some opaque userdata with a query object.
asyncns_cancel
void asyncns_cancel(asyncns_t *asyncns, asyncns_query_t *q)
Cancel a currently running query.
asyncns_res_search
asyncns_query_t * asyncns_res_search(asyncns_t *asyncns, const char *dname, int class, int type)
Issue an resolver query on the specified session.
asyncns_getnqueries
int asyncns_getnqueries(asyncns_t *asyncns)
Return the number of query objects (completed or not) attached to this session.
asyncns_getuserdata
void * asyncns_getuserdata(asyncns_t *asyncns, asyncns_query_t *q)
Return userdata assigned to a query object.
asyncns_res_done
int asyncns_res_done(asyncns_t *asyncns, asyncns_query_t *q, unsigned char **answer)
Retrieve the results of a preceding asyncns_res_query() or asyncns_res_search call.