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;
43 /* connection related */
45 struct sockaddr_in6 Addr;
51 ev_cleanup abort_by_shutdown;
59 StrBuf *ErrMsg; /* if we fail to connect, or lookup, error goes here. */
61 /* read/send related... */
66 /* Citadel application callbacks... */
67 IO_CallBack ReadDone, /* Theres new data to read... */
68 SendDone, /* we may send more data */
69 Terminate, /* shutting down... */
70 Timeout, /* Timeout handler; may also be connection timeout */
71 ConnFail, /* What to do when one connection failed? */
72 ShutdownAbort;/* we're going down. make your piece. */
74 IO_LineReaderCallback LineReader; /* if we have linereaders, maybe we want to read more lines before the real application logic is called? */
78 struct ares_options DNSOptions;
79 ares_channel DNSChannel;
80 DNSQueryParts *DNSQuery;
82 /* Custom data; its expected to contain AsyncIO so we can save malloc()s... */
83 DeleteHashDataFunc DeleteData; /* so if we have to destroy you, what to do... */
84 void *Data; /* application specific data */
87 typedef struct _IOAddHandler {
92 void FreeAsyncIOContents(AsyncIO *IO);
94 int QueueEventContext(AsyncIO *IO, IO_CallBack CB);
95 int ShutDownEventQueue(void);
97 eNextState InitEventIO(AsyncIO *IO,
100 double first_rw_timeout,
102 void IO_postdns_callback(struct ev_loop *loop, ev_idle *watcher, int revents);
104 int QueueQuery(ns_type Type, const char *name, AsyncIO *IO, DNSQueryParts *QueryParts, IO_CallBack PostDNS);
105 void QueueGetHostByName(AsyncIO *IO, const char *Hostname, DNSQueryParts *QueryParts, IO_CallBack PostDNS);
107 void QueryCbDone(AsyncIO *IO);
109 void StopClient(AsyncIO *IO);
111 void SetNextTimeout(AsyncIO *IO, double timeout);
113 void InitC_ares_dns(AsyncIO *IO);