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
|
/**
@file rexmpp_dns.h
@brief DNS helper functions
@author defanor <defanor@uberspace.net>
@date 2020
@copyright MIT license.
*/
#ifndef REXMPP_DNS_H
#define REXMPP_DNS_H
#include <stdint.h>
#include "config.h"
#include "rexmpp.h"
#if defined(USE_UNBOUND)
#include <unbound.h>
struct rexmpp_dns_ctx {
struct ub_ctx *ctx;
};
#else
struct rexmpp_dns_ctx {
int dummy;
};
#endif
typedef struct rexmpp_dns_ctx rexmpp_dns_ctx_t;
struct rexmpp_dns_srv {
uint16_t priority;
uint16_t weight;
uint16_t port;
char target[256];
};
struct rexmpp_dns_result {
char **data;
int *len;
char *qname;
int secure;
};
/**
@brief Parses an SRV DNS RR's RDATA.
@param[in] in SRV record's RDATA.
@param[in] in_len Length of the input data in octets.
@param[out] out A structure to fill with data.
@returns 0 on success, non-zero on parsing failure.
*/
int
rexmpp_parse_srv (char *in, int in_len, struct rexmpp_dns_srv *out);
typedef struct rexmpp_dns_result rexmpp_dns_result_t;
/* struct rexmpp_dns_result *rexmpp_dns_result_init (int len); */
void rexmpp_dns_result_free (rexmpp_dns_result_t *result);
int rexmpp_dns_ctx_init (rexmpp_t *s);
void rexmpp_dns_ctx_cleanup (rexmpp_t *s);
void rexmpp_dns_ctx_deinit (rexmpp_t *s);
int rexmpp_dns_fds (rexmpp_t *s, fd_set *read_fds, fd_set *write_fds);
struct timeval * rexmpp_dns_timeout (rexmpp_t *s,
struct timeval *max_tv,
struct timeval *tv);
typedef void (*dns_query_cb_t) (rexmpp_t *s, void *ptr, rexmpp_dns_result_t *result);
int rexmpp_dns_resolve (rexmpp_t *s,
const char *query,
int rrtype,
int rrclass,
void* ptr,
dns_query_cb_t callback);
int rexmpp_dns_process (rexmpp_t *s, fd_set *read_fds, fd_set *write_fds);
#endif
|