2018-07-16 12:48:38 +00:00
|
|
|
#ifndef LLARP_DNS_H_
|
|
|
|
#define LLARP_DNS_H_
|
|
|
|
|
2018-07-25 00:35:11 +00:00
|
|
|
#include <llarp/ev.h> // for sockaadr
|
2018-07-21 13:24:47 +00:00
|
|
|
#include <sys/types.h> // for uint & ssize_t
|
2018-07-25 00:35:11 +00:00
|
|
|
#include <map> // for udp DNS tracker
|
2018-07-16 12:48:38 +00:00
|
|
|
|
2018-07-30 04:38:14 +00:00
|
|
|
/* non-cygnus does not have this type */
|
|
|
|
#ifdef _WIN32
|
|
|
|
#define uint UINT
|
|
|
|
#endif
|
|
|
|
|
2018-07-16 23:26:58 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
2018-07-21 13:19:06 +00:00
|
|
|
{
|
2018-07-16 23:26:58 +00:00
|
|
|
#endif
|
|
|
|
/**
|
|
|
|
* dns.h
|
|
|
|
*
|
|
|
|
* dns client/server
|
|
|
|
*/
|
2018-07-16 12:48:38 +00:00
|
|
|
|
2018-07-24 01:43:32 +00:00
|
|
|
//#include <mutex>
|
2018-07-25 00:35:11 +00:00
|
|
|
// typedef std::mutex mtx_t;
|
|
|
|
// typedef std::lock_guard< mtx_t > lock_t;
|
2018-07-16 12:48:38 +00:00
|
|
|
|
2018-07-24 01:43:32 +00:00
|
|
|
// fwd declr
|
2018-07-25 00:35:11 +00:00
|
|
|
// struct dns_query;
|
2018-07-24 01:43:32 +00:00
|
|
|
struct dnsc_context;
|
|
|
|
struct dnsd_context;
|
2018-07-25 00:35:11 +00:00
|
|
|
// struct dnsd_question_request;
|
2018-07-24 01:43:32 +00:00
|
|
|
struct dnsc_answer_request;
|
2018-07-16 12:48:38 +00:00
|
|
|
|
2018-07-24 01:43:32 +00:00
|
|
|
// dnsc can work over any UDP socket
|
|
|
|
// however we can't ignore udp->user
|
|
|
|
// we need to be able to reference the request (being a request or response)
|
|
|
|
// bottom line is we can't use udp->user
|
|
|
|
// so we'll need to track all incoming and outgoing requests
|
2018-07-16 12:48:38 +00:00
|
|
|
|
2018-07-27 04:07:22 +00:00
|
|
|
struct dns_tracker;
|
2018-07-16 23:26:58 +00:00
|
|
|
|
2018-07-24 01:43:32 +00:00
|
|
|
// should we pass by llarp::Addr
|
|
|
|
// not as long as we're supporting raw
|
|
|
|
typedef void (*dnsc_answer_hook_func)(dnsc_answer_request *request);
|
2018-07-16 12:48:38 +00:00
|
|
|
|
2018-07-16 23:26:58 +00:00
|
|
|
struct sockaddr *
|
2018-07-24 01:43:32 +00:00
|
|
|
raw_resolve_host(const char *url);
|
2018-07-16 23:26:58 +00:00
|
|
|
|
|
|
|
/// async resolve hostname
|
|
|
|
bool
|
2018-07-24 01:43:32 +00:00
|
|
|
llarp_resolve_host(struct dnsc_context *dns, const char *url,
|
|
|
|
dnsc_answer_hook_func resolved, void *user);
|
|
|
|
void
|
|
|
|
llarp_host_resolved(dnsc_answer_request *request);
|
2018-07-16 23:26:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
// XXX: these should be internal and not exposed
|
|
|
|
|
|
|
|
void
|
|
|
|
llarp_handle_recvfrom(struct llarp_udp_io *udp, const struct sockaddr *saddr,
|
|
|
|
const void *buf, ssize_t sz);
|
|
|
|
void
|
|
|
|
raw_handle_recvfrom(int *sockfd, const struct sockaddr *saddr, const void
|
|
|
|
*buf, ssize_t sz);
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2018-07-16 12:48:38 +00:00
|
|
|
#endif
|