1 /* IODNSLookup.h - IOMultiplexer v2
2 * Copyright (C) 2014 Philipp Kreil (pk910)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef _IODNSLookup_h
18 #define _IODNSLookup_h
19 #ifndef _IOHandler_internals
20 #include "IOHandler.h"
23 extern struct IODNSEngine dnsengine_cares;
24 extern struct IODNSEngine dnsengine_default;
27 extern pthread_mutex_t iodns_sync;
32 #define IODNSFLAG_RUNNING 0x01
33 #define IODNSFLAG_PROCESSING 0x02
34 #define IODNSFLAG_PARENT_PUBLIC 0x04
39 unsigned int flags : 8;
40 unsigned int type : 8;
42 struct IODNSAddress addr;
46 struct IODNSResult *result;
50 struct _IODNSQuery *next, *prev;
57 void (*add)(struct _IODNSQuery *query);
58 void (*remove)(struct _IODNSQuery *query);
64 struct _IODNSQuery *_create_dnsquery();
65 void _start_dnsquery(struct _IODNSQuery *query);
66 void _stop_dnsquery(struct _IODNSQuery *query);
68 /* call only from engines! */
69 void _free_dnsquery(struct _IODNSQuery *query)
70 void iodns_event_callback(struct _IODNSQuery *query, enum IODNSEventType state);
76 #define IODNS_CALLBACK(NAME) void NAME(struct IODNSEvent *event)
77 typedef IODNS_CALLBACK(iodns_callback);
84 #define IODNS_RECORD_A 0x01
85 #define IODNS_RECORD_AAAA 0x02
86 #define IODNS_RECORD_PTR 0x04
88 #define IODNS_FORWARD 0x03
89 #define IODNS_REVERSE 0x04
93 struct sockaddr *address;
99 iodns_callback *callback;
104 unsigned int type : 8;
106 struct IODNSAddress addr;
109 struct IODNSResult *next;
113 enum IODNSEventType type;
114 struct IODNSQuery *query;
115 struct IODNSResult *result;
118 struct IODNSQuery *iodns_getaddrinfo(char *hostname, int records, iodns_callback *callback);
119 struct IODNSQuery *iodns_getnameinfo(const struct sockaddr *addr, socklen_t addrlen, iodns_callback *callback);
120 void iodns_abort(struct IODNSQuery *query);
122 void iodns_free_result(struct IODNSResult *result);