2 This file is part of GNUnet
3 Copyright (C) 2012 GNUnet e.V.
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.
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.
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @author Christian Grothoff
25 * API for helper library to send DNS requests to DNS resolver
27 * @defgroup dns-stub DNS Stub library
28 * Helper library to send DNS requests to DNS resolver
31 #ifndef GNUNET_DNSSTUB_LIB_H
32 #define GNUNET_DNSSTUB_LIB_H
34 #include "gnunet_common.h"
35 #include "gnunet_tun_lib.h"
38 * Opaque handle to the stub resolver.
40 struct GNUNET_DNSSTUB_Context;
43 * Opaque handle to a socket doing UDP requests.
45 struct GNUNET_DNSSTUB_RequestSocket;
49 * Start a DNS stub resolver.
51 * @param dns_ip target IP address to use
52 * @return NULL on error
54 struct GNUNET_DNSSTUB_Context *
55 GNUNET_DNSSTUB_start (const char *dns_ip);
59 * Cleanup DNSSTUB resolver.
61 * @param ctx stub resolver to clean up
64 GNUNET_DNSSTUB_stop (struct GNUNET_DNSSTUB_Context *ctx);
68 * Function called with the result of a DNS resolution.
71 * @param rs socket that received the response
72 * @param dns dns response, never NULL
73 * @param dns_len number of bytes in @a dns
76 (*GNUNET_DNSSTUB_ResultCallback)(void *cls,
77 struct GNUNET_DNSSTUB_RequestSocket *rs,
78 const struct GNUNET_TUN_DnsHeader *dns,
83 * Perform DNS resolution using given address.
85 * @param ctx stub resolver to use
86 * @param sa the socket address
87 * @param sa_len the socket length
88 * @param request DNS request to transmit
89 * @param request_len number of bytes in msg
90 * @param rc function to call with result
91 * @param rc_cls closure for @a rc
92 * @return socket used for the request, NULL on error
94 struct GNUNET_DNSSTUB_RequestSocket *
95 GNUNET_DNSSTUB_resolve (struct GNUNET_DNSSTUB_Context *ctx,
96 const struct sockaddr *sa,
100 GNUNET_DNSSTUB_ResultCallback rc,
105 * Perform DNS resolution using our default IP from init.
107 * @param ctx stub resolver to use
108 * @param request DNS request to transmit
109 * @param request_len number of bytes in msg
110 * @param rc function to call with result
111 * @param rc_cls closure for @a rc
112 * @return socket used for the request, NULL on error
114 struct GNUNET_DNSSTUB_RequestSocket *
115 GNUNET_DNSSTUB_resolve2 (struct GNUNET_DNSSTUB_Context *ctx,
118 GNUNET_DNSSTUB_ResultCallback rc,
123 * Cancel DNS resolution.
125 * @param rs resolution to cancel
128 GNUNET_DNSSTUB_resolve_cancel (struct GNUNET_DNSSTUB_RequestSocket *rs);
133 /** @} */ /* end of group */