-
Notifications
You must be signed in to change notification settings - Fork 0
/
ares_dns.h
103 lines (80 loc) · 2.76 KB
/
ares_dns.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// SPDX-License-Identifier: MIT
#ifndef IOUCONTEXT_ARES_DNS_H
#define IOUCONTEXT_ARES_DNS_H
#include <stdarg.h>
#include <sys/socket.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct reactor_s reactor_t;
typedef struct ares_channeldata ares_channel_t;
struct ares_options;
typedef struct iou_ares_data_s {
reactor_t * reactor;
ares_channel_t * channel;
int epfd;
unsigned waiters;
} iou_ares_data_t;
ares_channel_t * iou_ares_get(reactor_t *, iou_ares_data_t * data, const struct ares_options * options, int optmask);
void iou_ares_cancel(iou_ares_data_t * data);
void iou_ares_put(iou_ares_data_t * data);
typedef struct todo_sigjmp_s todo_sigjmp_t;
typedef struct iou_ares_future_s {
iou_ares_data_t * data;
todo_sigjmp_t * todo;
} iou_ares_future_t;
int iou_ares__wait(iou_ares_future_t * result, ...);
#define iou_ares_wait(...) iou_ares__wait(__VA_ARGS__, (iou_ares_future_t *)NULL)
struct ares_dns_record;
typedef struct iou_ares_result_s {
iou_ares_future_t future;
int status;
int timeouts;
unsigned int flags;
struct ares_dns_record *dnsrec;
} iou_ares_result_t;
iou_ares_result_t * iou_ares_search(
iou_ares_data_t * data,
const char *name,
int dnsclass, int type,
unsigned int flags,
iou_ares_result_t * result);
void iou_ares_result_free(iou_ares_result_t * result);
struct ares_addrinfo;
struct ares_addrinfo_hints;
struct ares_addrinfo_node;
typedef struct iou_ares_addr_result_s {
iou_ares_future_t future;
int status;
int timeouts;
struct ares_addrinfo * addrinfo;
} iou_ares_addr_result_t;
iou_ares_addr_result_t * iou_ares_addrinfo(
iou_ares_data_t * data,
const char *name, const char *service,
const struct ares_addrinfo_hints *hints,
iou_ares_addr_result_t * result);
int iou_ares_dial(reactor_t *, struct ares_addrinfo *addrinfo, struct timespec delta);
int iou_ares_dial_node(reactor_t *, struct ares_addrinfo_node *node, struct timespec delta);
#define for_ares_addrinfo_cnames(CNAME, ADDRINFO) \
for (struct ares_addrinfo_cname * (CNAME) = (ADDRINFO).cnames ; (CNAME) ; (CNAME) = (CNAME)->next)
#define for_ares_addrinfo_nodes(NODE, ADDRINFO) \
for (struct ares_addrinfo_node * (NODE) = (ADDRINFO).nodes ; (NODE) ; (NODE) = (NODE)->ai_next)
void iou_ares_addr_free(iou_ares_addr_result_t * result);
typedef struct iou_ares_name_result_s {
iou_ares_future_t future;
int status;
int timeouts;
char * node;
char * service;
} iou_ares_name_result_t;
iou_ares_name_result_t * iou_ares_nameinfo(
iou_ares_data_t * data,
const struct sockaddr * sockaddr, socklen_t socklen,
int flags,
iou_ares_name_result_t * result);
void iou_ares_name_free(iou_ares_name_result_t * result);
#ifdef __cplusplus
}
#endif
#endif//IOUCONTEXT_ARES_DNS_H