3 #include <sys/socket.h>
5 #include <arpa/nameser.h>
8 typedef struct AsyncIO AsyncIO;
10 typedef enum _eNextState {
18 typedef eNextState (*IO_CallBack)(AsyncIO *IO);
19 typedef eReadState (*IO_LineReaderCallback)(AsyncIO *IO);
20 typedef void (*ParseDNSAnswerCb)(AsyncIO*, unsigned char*, int);
21 typedef void (*FreeDNSReply)(void *DNSData);
23 typedef struct _DNSQueryParts {
24 ParseDNSAnswerCb DNS_CB;
28 void *VParsedDNSReply;
29 FreeDNSReply DNSReplyFree;
36 /* connection related */
40 struct sockaddr_in6 *Addr;
47 ev_cleanup abort_by_shutdown;
55 StrBuf *ErrMsg; /* if we fail to connect, or lookup, error goes here. */
57 /* read/send related... */
62 /* Citadel application callbacks... */
63 IO_CallBack ReadDone, /* Theres new data to read... */
64 SendDone, /* we may send more data */
65 Terminate, /* shutting down... */
66 Timeout, /* Timeout handler; may also be connection timeout */
67 ConnFail, /* What to do when one connection failed? */
68 ShutdownAbort;/* we're going down. make your piece. */
70 IO_LineReaderCallback LineReader; /* if we have linereaders, maybe we want to read more lines before the real application logic is called? */
74 struct ares_options DNSOptions;
75 ares_channel DNSChannel;
76 DNSQueryParts *DNSQuery;
78 /* Custom data; its expected to contain AsyncIO so we can save malloc()s... */
79 DeleteHashDataFunc DeleteData; /* so if we have to destroy you, what to do... */
80 void *Data; /* application specific data */
83 typedef struct _IOAddHandler {
88 void FreeAsyncIOContents(AsyncIO *IO);
90 int QueueEventContext(AsyncIO *IO, IO_CallBack CB);
91 int ShutDownEventQueue(void);
93 eNextState InitEventIO(AsyncIO *IO,
96 double first_rw_timeout,
98 void IO_postdns_callback(struct ev_loop *loop, ev_idle *watcher, int revents);
100 int QueueQuery(ns_type Type, const char *name, AsyncIO *IO, DNSQueryParts *QueryParts, IO_CallBack PostDNS);
101 void QueueGetHostByName(AsyncIO *IO, const char *Hostname, DNSQueryParts *QueryParts, IO_CallBack PostDNS);
103 void QueryCbDone(AsyncIO *IO);
105 void StopClient(AsyncIO *IO);
107 void SetNextTimeout(AsyncIO *IO, double timeout);
109 void InitC_ares_dns(AsyncIO *IO);