47 #include <getdns/getdns.h>
48 #include <ldns/ldns.h>
58 CBN_HOSTNAME_TOO_LONG,
65 CBN_PKIX_DID_NOT_VALIDATE
70 enum cbn_status status;
77 getdns_callback_type_t callback_type;
78 getdns_return_t getdns_result;
80 ldns_status ldns_status;
84 #define SET_ERROR_GENERIC(errp, error_status) \
85 (errp)->status= error_status, \
86 (errp)->file= __FILE__, \
87 (errp)->line= __LINE__, \
88 (errp)->func= __func__
89 #define SET_ERROR_CALLBACK(errp, callback_type) \
90 SET_ERROR_GENERIC(errp, CBN_ERROR_CALLBACK), \
91 (errp)->u.callback_type= callback_type
92 #define SET_ERROR_GETDNS(errp, msgstr, r) \
93 SET_ERROR_GENERIC(errp, CBN_GETDNS_ERROR), \
94 (errp)->msg= msgstr, \
95 (errp)->u.getdns_result= r
96 #define SET_ERROR_GETDNS_REPSTATUS(errp, msgstr, r) \
97 SET_ERROR_GENERIC(errp, CBN_GETDNS_REPSTATUS), \
98 (errp)->msg= msgstr, \
99 (errp)->u.getdns_repstatus= r
100 #define SET_ERROR_A_AAAA_TIMEOUT(errp) \
101 SET_ERROR_GENERIC(errp, CBN_A_AAAA_TIMEOUT)
102 #define SET_ERROR_LDNS(errp, msgstr) \
103 SET_ERROR_GENERIC(errp, CBN_LDNS_ERROR), \
105 #define SET_ERROR_LDNS_RESULT(errp, msgstr, r) \
106 SET_ERROR_GENERIC(errp, CBN_LDNS_RESULT), \
107 (errp)->msg= msgstr, \
108 (errp)->u.ldns_status= r
109 #define SET_ERROR_SSL(errp, msgstr) \
110 SET_ERROR_GENERIC(errp, CBN_SSL_ERROR), \
112 #define SET_ERROR_TLSA_MISMATCH(errp) \
113 SET_ERROR_GENERIC(errp, CBN_TLSA_MISMATCH)
114 #define SET_ERROR_DANE_TIMEOUT(errp) \
115 SET_ERROR_GENERIC(errp, CBN_DANE_TIMEOUT)
116 #define SET_ERROR_PKIX_DID_NOT_VALIDATE(errp) \
117 SET_ERROR_GENERIC(errp, CBN_PKIX_DID_NOT_VALIDATE)
120 typedef void (*cbn_callback_T)(
struct bufferevent *bev,
void *ref);
121 typedef void (*cbn_callback_error_T)(
struct cbn_error *error,
void *ref);
123 #define CBNPR_MAX_ADDRS 3
128 unsigned int settings;
131 struct sockaddr_storage addrs[CBNPR_MAX_ADDRS];
136 #define CBN_UNENCRYPTED (1 << 0)
137 #define CBN_UNAUTHENTICATED_ENCRYPTION (1 << 1)
138 #define CBN_AUTHENTICATED_ENCRYPTION (1 << 2)
139 #define CBN_PKIX_AUTH_REQUIRED (1 << 3)
140 #define CBN_DANE_AUTH_REQUIRED (1 << 4)
141 #define CBN_DEFAULT_DISALLOW_OTHER_TRANSPORTS (1 << 5)
142 #define CBN_ALLOW_DO53 (1 << 8)
143 #define CBN_DISALLOW_DO53 (1 << 9)
144 #define CBN_ALLOW_DOT (1 << 10)
145 #define CBN_DISALLOW_DOT (1 << 11)
146 #define CBN_ALLOW_DOH2 (1 << 12)
147 #define CBN_DISALLOW_DOH2 (1 << 13)
148 #define CBN_ALLOW_DOH3 (1 << 14)
149 #define CBN_DISALLOW_DOH3 (1 << 15)
150 #define CBN_ALLOW_DOQ (1 << 16)
151 #define CBN_DISALLOW_DOQ (1 << 17)
153 #define MAX_RESOLVERS 10
163 struct event_base *event_base;
164 getdns_context *getdns_ctx;
180 struct cbn_policy *policy,
const char *name,
unsigned int settings);
200 static inline struct cbn_policy *cbn_policy_new()
230 char *name,
int flags,
struct event_base *event_base);
247 const char *hostname,
const char *servname,
int *fdp);
261 const char *hostname,
const char *servname,
262 cbn_callback_T user_cb, cbn_callback_error_T error_cb,
263 void *user_ref,
void **refp);
int cbn_policy_add_resolver(struct cbn_policy *policy, struct cbnp_resolver *resolver)
Definition: connectbyname.c:189
int cbn_init(struct cbn_context *cbn_ctx, struct event_base *event_base)
Definition: connectbyname.c:142
void connectbyname_free(void *ref)
Definition: connectbyname.c:352
int connectbyname_asyn(struct cbn_context *cbn_ctx, const char *hostname, const char *servname, cbn_callback_T user_cb, cbn_callback_error_T error_cb, void *user_ref, void **refp)
Definition: connectbyname.c:216
void cbn_clean(struct cbn_context *cbn_ctx)
Definition: connectbyname.c:176
int cbn_init2(struct cbn_context *cbn_ctx, struct cbn_policy *policy, char *name, int flags, struct event_base *event_base)
Definition: connectbyname.c:149
int connectbyname(struct cbn_context *cbn_ctx, const char *hostname, const char *servname, int *fdp)
struct cbn_policy * cbn_policy_init2(struct cbn_policy *policy, const char *name, unsigned int settings)
Definition: connectbyname.c:183
Definition: connectbyname.h:162
Definition: connectbyname.h:69
Definition: connectbyname.h:156
Definition: connectbyname.h:127