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;
38 /* To cycle through several possible services... */
40 struct addrinfo *curr_ai;
42 /* connection related */
44 struct sockaddr_in6 Addr;
50 ev_cleanup abort_by_shutdown;
58 StrBuf *ErrMsg; /* if we fail to connect, or lookup, error goes here. */
60 /* read/send related... */
65 /* Citadel application callbacks... */
66 IO_CallBack ReadDone, /* Theres new data to read... */
67 SendDone, /* we may send more data */
68 Terminate, /* shutting down... */
69 Timeout, /* Timeout handler; may also be connection timeout */
70 ConnFail, /* What to do when one connection failed? */
71 ShutdownAbort;/* we're going down. make your piece. */
73 IO_LineReaderCallback LineReader; /* if we have linereaders, maybe we want to read more lines before the real application logic is called? */
77 struct ares_options DNSOptions;
78 ares_channel DNSChannel;
79 DNSQueryParts *DNSQuery;
81 /* Custom data; its expected to contain AsyncIO so we can save malloc()s... */
82 DeleteHashDataFunc DeleteData; /* so if we have to destroy you, what to do... */
83 void *Data; /* application specific data */
86 typedef struct _IOAddHandler {
91 void FreeAsyncIOContents(AsyncIO *IO);
93 int QueueEventContext(AsyncIO *IO, IO_CallBack CB);
94 int ShutDownEventQueue(void);
96 eNextState InitEventIO(AsyncIO *IO,
99 double first_rw_timeout,
101 void IO_postdns_callback(struct ev_loop *loop, ev_idle *watcher, int revents);
103 int QueueQuery(ns_type Type, const char *name, AsyncIO *IO, DNSQueryParts *QueryParts, IO_CallBack PostDNS);
104 void QueueGetHostByName(AsyncIO *IO, const char *Hostname, DNSQueryParts *QueryParts, IO_CallBack PostDNS);
106 void QueryCbDone(AsyncIO *IO);
108 void StopClient(AsyncIO *IO);
110 void SetNextTimeout(AsyncIO *IO, double timeout);
112 void InitC_ares_dns(AsyncIO *IO);