2012-06-19 05:20:39 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Haiku, Inc. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Paweł Dziepak, pdziepak@quarnos.org
|
|
|
|
*/
|
|
|
|
#ifndef DNS_RESOLVER_H
|
|
|
|
#define DNS_RESOLVER_H
|
|
|
|
|
|
|
|
|
2012-07-05 03:25:17 +04:00
|
|
|
#include <netdb.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2012-06-19 05:20:39 +04:00
|
|
|
#include <module.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define DNS_RESOLVER_MODULE_NAME "network/dns_resolver/v1"
|
|
|
|
|
|
|
|
|
|
|
|
struct dns_resolver_module {
|
2012-07-05 03:25:17 +04:00
|
|
|
module_info module;
|
|
|
|
status_t (*getaddrinfo)(const char* node, const char* service,
|
|
|
|
const struct addrinfo* hints, struct addrinfo** res);
|
2012-06-19 05:20:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-07-05 03:25:17 +04:00
|
|
|
static inline int
|
2012-08-16 05:41:29 +04:00
|
|
|
kgetaddrinfo(const char* node, const char* service,
|
|
|
|
const struct addrinfo* hints, struct addrinfo** res)
|
2012-07-05 03:25:17 +04:00
|
|
|
{
|
|
|
|
dns_resolver_module* dns;
|
|
|
|
status_t result = get_module(DNS_RESOLVER_MODULE_NAME,
|
|
|
|
reinterpret_cast<module_info**>(&dns));
|
|
|
|
if (result != B_OK)
|
|
|
|
return result;
|
|
|
|
|
|
|
|
result = dns->getaddrinfo(node, service, hints, res);
|
|
|
|
|
|
|
|
put_module(DNS_RESOLVER_MODULE_NAME);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline void
|
2012-08-16 05:41:29 +04:00
|
|
|
kfreeaddrinfo(struct addrinfo* res)
|
2012-07-05 03:25:17 +04:00
|
|
|
{
|
|
|
|
free(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-16 05:41:29 +04:00
|
|
|
#define getaddrinfo kgetaddrinfo
|
|
|
|
#define freeaddrinfo kfreeaddrinfo
|
|
|
|
|
|
|
|
|
2012-06-19 05:20:39 +04:00
|
|
|
#endif // DNS_RESOLVER_H
|
|
|
|
|