aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_dnsstub_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-04-19 18:38:41 +0200
committerChristian Grothoff <christian@grothoff.org>2018-04-19 18:38:41 +0200
commitff4d7b51f37f61633766664647e9b148af1e4f0a (patch)
tree500aa14d9452ce90c19dbbb18cfaec0dd51e6ec2 /src/include/gnunet_dnsstub_lib.h
parent9c699755967529e59815561d03b85e9a90d789f8 (diff)
downloadgnunet-ff4d7b51f37f61633766664647e9b148af1e4f0a.tar.gz
gnunet-ff4d7b51f37f61633766664647e9b148af1e4f0a.zip
support multiple DNS resolvers for queries (in DNSSTUB and GNS2DNS resolution for now)
Diffstat (limited to 'src/include/gnunet_dnsstub_lib.h')
-rw-r--r--src/include/gnunet_dnsstub_lib.h85
1 files changed, 51 insertions, 34 deletions
diff --git a/src/include/gnunet_dnsstub_lib.h b/src/include/gnunet_dnsstub_lib.h
index 1c3305f7b..41e30d044 100644
--- a/src/include/gnunet_dnsstub_lib.h
+++ b/src/include/gnunet_dnsstub_lib.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 Copyright (C) 2012 GNUnet e.V. 3 Copyright (C) 2012, 2018 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
@@ -48,14 +48,52 @@ struct GNUNET_DNSSTUB_RequestSocket;
48/** 48/**
49 * Start a DNS stub resolver. 49 * Start a DNS stub resolver.
50 * 50 *
51 * @param dns_ip target IP address to use 51 * @param num_sockets how many sockets should we open
52 * in parallel for DNS queries for this stub?
52 * @return NULL on error 53 * @return NULL on error
53 */ 54 */
54struct GNUNET_DNSSTUB_Context * 55struct GNUNET_DNSSTUB_Context *
55GNUNET_DNSSTUB_start (const char *dns_ip); 56GNUNET_DNSSTUB_start (unsigned int num_sockets);
56 57
57 58
58/** 59/**
60 * Add nameserver for use by the DNSSTUB. We will use
61 * all provided nameservers for resolution (round-robin).
62 *
63 * @param ctx resolver context to modify
64 * @param dns_ip target IP address to use (as string)
65 * @return #GNUNET_OK on success
66 */
67int
68GNUNET_DNSSTUB_add_dns_ip (struct GNUNET_DNSSTUB_Context *ctx,
69 const char *dns_ip);
70
71
72/**
73 * Add nameserver for use by the DNSSTUB. We will use
74 * all provided nameservers for resolution (round-robin).
75 *
76 * @param ctx resolver context to modify
77 * @param sa socket address of DNS resolver to use
78 * @return #GNUNET_OK on success
79 */
80int
81GNUNET_DNSSTUB_add_dns_sa (struct GNUNET_DNSSTUB_Context *ctx,
82 const struct sockaddr *sa);
83
84
85/**
86 * How long should we try requests before timing out?
87 * Only effective for requests issued after this call.
88 *
89 * @param ctx resolver context to modify
90 * @param retry_frequ how long to wait between retries
91 */
92void
93GNUNET_DNSSTUB_set_retry (struct GNUNET_DNSSTUB_Context *ctx,
94 struct GNUNET_TIME_Relative retry_freq);
95
96/**
59 * Cleanup DNSSTUB resolver. 97 * Cleanup DNSSTUB resolver.
60 * 98 *
61 * @param ctx stub resolver to clean up 99 * @param ctx stub resolver to clean up
@@ -66,57 +104,36 @@ GNUNET_DNSSTUB_stop (struct GNUNET_DNSSTUB_Context *ctx);
66 104
67/** 105/**
68 * Function called with the result of a DNS resolution. 106 * Function called with the result of a DNS resolution.
107 * Once this function is called, the resolution request
108 * is automatically cancelled / cleaned up. In particular,
109 * the function will only be called once.
69 * 110 *
70 * @param cls closure 111 * @param cls closure
71 * @param rs socket that received the response 112 * @param dns dns response, NULL on hard error (i.e. timeout)
72 * @param dns dns response, never NULL
73 * @param dns_len number of bytes in @a dns 113 * @param dns_len number of bytes in @a dns
74 */ 114 */
75typedef void 115typedef void
76(*GNUNET_DNSSTUB_ResultCallback)(void *cls, 116(*GNUNET_DNSSTUB_ResultCallback)(void *cls,
77 struct GNUNET_DNSSTUB_RequestSocket *rs,
78 const struct GNUNET_TUN_DnsHeader *dns, 117 const struct GNUNET_TUN_DnsHeader *dns,
79 size_t dns_len); 118 size_t dns_len);
80 119
81 120
82/** 121/**
83 * Perform DNS resolution using given address.
84 *
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
93 */
94struct GNUNET_DNSSTUB_RequestSocket *
95GNUNET_DNSSTUB_resolve (struct GNUNET_DNSSTUB_Context *ctx,
96 const struct sockaddr *sa,
97 socklen_t sa_len,
98 const void *request,
99 size_t request_len,
100 GNUNET_DNSSTUB_ResultCallback rc,
101 void *rc_cls);
102
103
104/**
105 * Perform DNS resolution using our default IP from init. 122 * Perform DNS resolution using our default IP from init.
106 * 123 *
107 * @param ctx stub resolver to use 124 * @param ctx stub resolver to use
108 * @param request DNS request to transmit 125 * @param request DNS request to transmit
109 * @param request_len number of bytes in msg 126 * @param request_len number of bytes in msg
110 * @param rc function to call with result 127 * @param rc function to call with result (once)
111 * @param rc_cls closure for @a rc 128 * @param rc_cls closure for @a rc
112 * @return socket used for the request, NULL on error 129 * @return socket used for the request, NULL on error
113 */ 130 */
114struct GNUNET_DNSSTUB_RequestSocket * 131struct GNUNET_DNSSTUB_RequestSocket *
115GNUNET_DNSSTUB_resolve2 (struct GNUNET_DNSSTUB_Context *ctx, 132GNUNET_DNSSTUB_resolve (struct GNUNET_DNSSTUB_Context *ctx,
116 const void *request, 133 const void *request,
117 size_t request_len, 134 size_t request_len,
118 GNUNET_DNSSTUB_ResultCallback rc, 135 GNUNET_DNSSTUB_ResultCallback rc,
119 void *rc_cls); 136 void *rc_cls);
120 137
121 138
122/** 139/**