+/* IODNSHandler.h - IOMultiplexer
+ * Copyright (C) 2012 Philipp Kreil (pk910)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _IODNSHandler_h
+#define _IODNSHandler_h
+
+
+#define IODNS_CALLBACK(NAME) void NAME(struct IODNSEvent *event)
+typedef IODNS_CALLBACK(iodns_callback);
+
+enum IODNSEventType {
+ IODNSEVENT_SUCCESS,
+ IODNSEVENT_FAILED
+};
+
+#define IODNS_RECORD_A 0x01
+#define IODNS_RECORD_AAAA 0x02
+#define IODNS_RECORD_PTR 0x04
+
+#define IODNS_FORWARD 0x03
+#define IODNS_REVERSE 0x04
+
+struct IODNSQuery {
+ void *query;
+ unsigned int type : 8;
+ char *hostname;
+ size_t addresslen;
+ union {
+ struct sockaddr *address;
+ struct IODNSResult *results
+ } addr;
+ iodns_callback *callback;
+ void *data;
+
+ struct IODNSQuery *next, *prev;
+};
+
+struct IODNSResult {
+ unsigned int type : 8;
+ size_t addresslen;
+ struct sockaddr *address;
+ struct IODNSResult *next;
+};
+
+struct IODNSEvent {
+ enum IODNSEventType type;
+ struct IODNSQuery *query;
+};
+
+struct IODNSQuery *iodns_getaddrinfo(char *hostname, int records, iodns_callback *callback);
+struct IODNSQuery *iodns_getnameinfo(const struct sockaddr *addr, socklen_t addrlen, iodns_callback *callback);
+void iodns_abort(struct IODNSQuery *query);
+void iodns_poll();
+
+void iodns_free_result(struct IODNSResult *result);
+
+#endif