aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_dnsstub_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_dnsstub_lib.h')
-rw-r--r--src/include/gnunet_dnsstub_lib.h115
1 files changed, 115 insertions, 0 deletions
diff --git a/src/include/gnunet_dnsstub_lib.h b/src/include/gnunet_dnsstub_lib.h
new file mode 100644
index 000000000..ffe82dbbe
--- /dev/null
+++ b/src/include/gnunet_dnsstub_lib.h
@@ -0,0 +1,115 @@
1/*
2 This file is part of GNUnet
3 (C) 2012 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 */
20
21/**
22 * @file include/gnunet_dnsstub_lib.h
23 * @brief API for helper library to send DNS requests to DNS resolver
24 * @author Christian Grothoff
25 */
26#ifndef GNUNET_DNSSTUB_LIB_H
27#define GNUNET_DNSSTUB_LIB_H
28
29#include "gnunet_common.h"
30#include "gnunet_tun_lib.h"
31
32/**
33 * Opaque handle to the stub resolver.
34 */
35struct GNUNET_DNSSTUB_Context;
36
37/**
38 * Opaque handle to a socket doing UDP requests.
39 */
40struct GNUNET_DNSSTUB_RequestSocket;
41
42
43/**
44 * Start a DNS stub resolver.
45 *
46 * @param dns_ip target IP address to use
47 * @return NULL on error
48 */
49struct GNUNET_DNSSTUB_Context *
50GNUNET_DNSSTUB_start (const char *dns_ip);
51
52
53/**
54 * Cleanup DNSSTUB resolver.
55 *
56 * @param ctx stub resolver to clean up
57 */
58void
59GNUNET_DNSSTUB_stop (struct GNUNET_DNSSTUB_Context *ctx);
60
61
62/**
63 * Function called with the result of a DNS resolution.
64 *
65 * @param cls closure
66 * @param rs socket that received the response
67 * @param dns dns response, never NULL
68 * @param dns_len number of bytes in 'dns'
69 */
70typedef void (*GNUNET_DNSSTUB_ResultCallback)(void *cls,
71 struct GNUNET_DNSSTUB_RequestSocket *rs,
72 const struct GNUNET_TUN_DnsHeader *dns,
73 size_t dns_len);
74
75
76/**
77 * Perform DNS resolution using given address.
78 *
79 * @param ctx stub resolver to use
80 * @param af address family to use
81 * @param request DNS request to transmit
82 * @param request_len number of bytes in msg
83 * @param rc function to call with result
84 * @param rc_cls closure for 'rc'
85 * @return socket used for the request, NULL on error
86 */
87struct GNUNET_DNSSTUB_RequestSocket *
88GNUNET_DNSSTUB_resolve (struct GNUNET_DNSSTUB_Context *ctx,
89 const struct sockaddr *sa,
90 socklen_t sa_len,
91 const void *request,
92 size_t request_len,
93 GNUNET_DNSSTUB_ResultCallback rc,
94 void *rc_cls);
95
96
97/**
98 * Perform DNS resolution using our default IP from init.
99 *
100 * @param ctx stub resolver to use
101 * @param request DNS request to transmit
102 * @param request_len number of bytes in msg
103 * @param rc function to call with result
104 * @param rc_cls closure for 'rc'
105 * @return socket used for the request, NULL on error
106 */
107struct GNUNET_DNSSTUB_RequestSocket *
108GNUNET_DNSSTUB_resolve2 (struct GNUNET_DNSSTUB_Context *ctx,
109 const void *request,
110 size_t request_len,
111 GNUNET_DNSSTUB_ResultCallback rc,
112 void *rc_cls);
113
114
115#endif