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
35 #define IODNSFLAG_PARENT_SOCKET 0x08
40 unsigned int flags : 8;
41 unsigned int type : 8;
43 struct IODNSAddress addr;
47 struct IODNSResult *result;
51 struct _IODNSQuery *next, *prev;
58 void (*add)(struct _IODNSQuery *query);
59 void (*remove)(struct _IODNSQuery *query);
65 struct _IODNSQuery *_create_dnsquery();
66 void _start_dnsquery(struct _IODNSQuery *query);
67 void _stop_dnsquery(struct _IODNSQuery *query);
69 /* call only from engines! */
70 void _free_dnsquery(struct _IODNSQuery *query)
71 void iodns_event_callback(struct _IODNSQuery *query, enum IODNSEventType state);
77 #define IODNS_CALLBACK(NAME) void NAME(struct IODNSEvent *event)
78 typedef IODNS_CALLBACK(iodns_callback);
85 #define IODNS_RECORD_A 0x01
86 #define IODNS_RECORD_AAAA 0x02
87 #define IODNS_RECORD_PTR 0x04
89 #define IODNS_FORWARD 0x03
90 #define IODNS_REVERSE 0x04
94 struct sockaddr *address;
100 iodns_callback *callback;
105 unsigned int type : 8;
107 struct IODNSAddress addr;
110 struct IODNSResult *next;
114 enum IODNSEventType type;
115 struct IODNSQuery *query;
116 struct IODNSResult *result;
119 struct IODNSQuery *iodns_getaddrinfo(char *hostname, int records, iodns_callback *callback);
120 struct IODNSQuery *iodns_getnameinfo(const struct sockaddr *addr, socklen_t addrlen, iodns_callback *callback);
121 void iodns_abort(struct IODNSQuery *query);
123 void iodns_free_result(struct IODNSResult *result);