X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2FIODNSHandler.h;fp=src%2FIODNSHandler.h;h=621afb79f42caae0cb8ddb6e2fa5c64863b84c3c;hb=e18ef9b450a0704ff5c55545f70e3f1ec215a5e6;hp=0000000000000000000000000000000000000000;hpb=5ad65e65d2234b02151ea7ca17e3fa9893a9b165;p=IOMultiplexer.git diff --git a/src/IODNSHandler.h b/src/IODNSHandler.h new file mode 100644 index 0000000..621afb7 --- /dev/null +++ b/src/IODNSHandler.h @@ -0,0 +1,70 @@ +/* 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 . + */ +#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