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);
27 /* To cycle through several possible services... */
29 struct addrinfo *curr_ai;
31 /* connection related */
34 struct sockaddr_in6 Addr;
46 StrBuf *ErrMsg; /* if we fail to connect, or lookup, error goes here. */
48 /* read/send related... */
53 /* Citadel application callbacks... */
54 IO_CallBack ReadDone, /* Theres new data to read... */
55 SendDone, /* we may send more data */
56 Terminate, /* shutting down... */
57 Timeout, /* Timeout handler; may also be connection timeout */
58 ConnFail; /* What to do when one connection failed? */
60 IO_LineReaderCallback LineReader; /* if we have linereaders, maybe we want to read more lines before the real application logic is called? */
66 struct ares_options DNSOptions;
67 ares_channel DNSChannel;
69 ParseDNSAnswerCb DNS_CB;
73 void *VParsedDNSReply;
74 FreeDNSReply DNSReplyFree;
76 /* Custom data; its expected to contain AsyncIO so we can save malloc()s... */
77 DeleteHashDataFunc DeleteData; /* so if we have to destroy you, what to do... */
78 void *Data; /* application specific data */
81 typedef struct _IOAddHandler {
86 void FreeAsyncIOContents(AsyncIO *IO);
88 int QueueEventContext(AsyncIO *IO, IO_CallBack CB);
89 int ShutDownEventQueue(void);
91 eNextState InitEventIO(AsyncIO *IO,
94 double first_rw_timeout,
96 void IO_postdns_callback(struct ev_loop *loop, ev_timer *watcher, int revents);
98 int QueueQuery(ns_type Type, char *name, AsyncIO *IO, IO_CallBack PostDNS);
99 void QueryCbDone(AsyncIO *IO);
101 void StopClient(AsyncIO *IO);
103 void SetNextTimeout(AsyncIO *IO, double timeout);
105 void InitC_ares_dns(AsyncIO *IO);