GNUnet  0.11.x
Data Structures | Macros | Functions | Variables
gnunet-dns2gns.c File Reference

DNS server that translates DNS requests to GNS. More...

#include "platform.h"
#include <gnunet_util_lib.h>
#include <gnunet_dnsparser_lib.h>
#include <gnunet_gns_service.h>
#include <gnunet_dnsstub_lib.h>
#include "gns.h"
Include dependency graph for gnunet-dns2gns.c:

Go to the source code of this file.

Data Structures

struct  Request
 Request we should make. More...
 

Macros

#define TIMEOUT   GNUNET_TIME_UNIT_MINUTES
 Timeout for DNS requests. More...
 

Functions

static void do_shutdown (void *cls)
 Task run on shutdown. More...
 
static void shuffle_answers (struct Request *request)
 Shuffle answers Fisher-Yates (aka Knuth) Shuffle. More...
 
static void send_response (struct Request *request)
 Send the response for the given request and clean up. More...
 
static void do_timeout (void *cls)
 Task run on timeout. More...
 
static void dns_result_processor (void *cls, const struct GNUNET_TUN_DnsHeader *dns, size_t r)
 Iterator called on obtained result for a DNS lookup. More...
 
static void result_processor (void *cls, int was_gns, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Iterator called on obtained result for a GNS lookup. More...
 
static void handle_request (struct GNUNET_NETWORK_Handle *lsock, const void *addr, size_t addr_len, const char *udp_msg, size_t udp_msg_size)
 Handle DNS request. More...
 
static void read_dns4 (void *cls)
 Task to read IPv4 DNS packets. More...
 
static void read_dns6 (void *cls)
 Task to read IPv6 DNS packets. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
 Main function that will be run. More...
 
int main (int argc, char *const *argv)
 The main function for the dns2gns daemon. More...
 

Variables

static in_addr_t address
 The address to bind to. More...
 
static struct in6_addr address6
 The IPv6 address to bind to. More...
 
struct GNUNET_GNS_Handlegns
 Handle to GNS resolver. More...
 
struct GNUNET_DNSSTUB_Contextdns_stub
 Stub resolver. More...
 
static struct GNUNET_NETWORK_Handlelisten_socket4
 Listen socket for IPv4. More...
 
static struct GNUNET_NETWORK_Handlelisten_socket6
 Listen socket for IPv6. More...
 
static struct GNUNET_SCHEDULER_Taskt4
 Task for IPv4 socket. More...
 
static struct GNUNET_SCHEDULER_Taskt6
 Task for IPv6 socket. More...
 
static char * dns_ip
 IP of DNS server. More...
 
static unsigned int listen_port = 53
 UDP Port we listen on for inbound DNS requests. More...
 
static const struct GNUNET_CONFIGURATION_Handlecfg
 Configuration to use. More...
 

Detailed Description

DNS server that translates DNS requests to GNS.

Author
Christian Grothoff

Definition in file gnunet-dns2gns.c.

Macro Definition Documentation

◆ TIMEOUT

#define TIMEOUT   GNUNET_TIME_UNIT_MINUTES

Timeout for DNS requests.

Definition at line 35 of file gnunet-dns2gns.c.

Referenced by handle_request().

Function Documentation

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Task run on shutdown.

Cleans up everything.

Parameters
clsunused

Definition at line 158 of file gnunet-dns2gns.c.

References GNUNET_DNSSTUB_stop(), GNUNET_GNS_disconnect(), GNUNET_NETWORK_socket_close(), and GNUNET_SCHEDULER_cancel().

Referenced by run().

159 {
160  (void) cls;
161  if (NULL != t4)
162  {
164  t4 = NULL;
165  }
166  if (NULL != t6)
167  {
169  t6 = NULL;
170  }
171  if (NULL != listen_socket4)
172  {
174  listen_socket4 = NULL;
175  }
176  if (NULL != listen_socket6)
177  {
179  listen_socket6 = NULL;
180  }
181  if (NULL != gns)
182  {
184  gns = NULL;
185  }
186  if (NULL != dns_stub)
187  {
189  dns_stub = NULL;
190  }
191 }
void GNUNET_DNSSTUB_stop(struct GNUNET_DNSSTUB_Context *ctx)
Cleanup DNSSTUB resolver.
Definition: dnsstub.c:690
static struct GNUNET_NETWORK_Handle * listen_socket4
Listen socket for IPv4.
struct GNUNET_GNS_Handle * gns
Handle to GNS resolver.
static struct GNUNET_SCHEDULER_Task * t4
Task for IPv4 socket.
void GNUNET_GNS_disconnect(struct GNUNET_GNS_Handle *handle)
Shutdown connection with the GNS service.
Definition: gns_api.c:290
static struct GNUNET_NETWORK_Handle * listen_socket6
Listen socket for IPv6.
struct GNUNET_DNSSTUB_Context * dns_stub
Stub resolver.
int GNUNET_NETWORK_socket_close(struct GNUNET_NETWORK_Handle *desc)
Close a socket.
Definition: network.c:560
static struct GNUNET_SCHEDULER_Task * t6
Task for IPv6 socket.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
Here is the call graph for this function:
Here is the caller graph for this function:

◆ shuffle_answers()

static void shuffle_answers ( struct Request request)
static

Shuffle answers Fisher-Yates (aka Knuth) Shuffle.

Parameters
requestcontext for the request (with answers)

Definition at line 201 of file gnunet-dns2gns.c.

References GNUNET_DNSPARSER_Packet::answers, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_DNSPARSER_Packet::num_answers, and Request::packet.

Referenced by send_response().

202 {
203  unsigned int idx = request->packet->num_answers;
204  unsigned int r_idx;
205  struct GNUNET_DNSPARSER_Record tmp_answer;
206 
207  while (0 != idx)
208  {
210  request->packet->num_answers);
211  idx--;
212  tmp_answer = request->packet->answers[idx];
213  memcpy (&request->packet->answers[idx], &request->packet->answers[r_idx],
214  sizeof (struct GNUNET_DNSPARSER_Record));
215  memcpy (&request->packet->answers[r_idx], &tmp_answer,
216  sizeof (struct GNUNET_DNSPARSER_Record));
217  }
218 }
struct GNUNET_DNSPARSER_Record * answers
Array of all answers in the packet, must contain "num_answers" entries.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
unsigned int num_answers
Number of answers in the packet, should be 0 for queries.
A DNS response record.
struct GNUNET_DNSPARSER_Packet * packet
Initially, this is the DNS request, it will then be converted to the DNS response.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_response()

static void send_response ( struct Request request)
static

Send the response for the given request and clean up.

Parameters
requestcontext for the request.

Definition at line 227 of file gnunet-dns2gns.c.

References _, Request::addr, Request::addr_len, buf, GNUNET_DNSPARSER_free_packet(), GNUNET_DNSPARSER_pack(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_strerror, GNUNET_NETWORK_socket_sendto(), GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, Request::lsock, Request::packet, shuffle_answers(), size, Request::timeout_task, and Request::udp_msg.

Referenced by dns_result_processor(), and result_processor().

228 {
229  char *buf;
230  size_t size;
231  ssize_t sret;
232 
233  shuffle_answers (request);
234  if (GNUNET_SYSERR ==
235  GNUNET_DNSPARSER_pack (request->packet,
236  UINT16_MAX /* is this not too much? */,
237  &buf,
238  &size))
239  {
241  _ ("Failed to pack DNS response into UDP packet!\n"));
242  }
243  else
244  {
245  sret = GNUNET_NETWORK_socket_sendto (request->lsock,
246  buf,
247  size,
248  request->addr,
249  request->addr_len);
250  if ((sret < 0) ||
251  (size != (size_t) sret))
253  "sendto");
254  GNUNET_free (buf);
255  }
258  GNUNET_free (request->udp_msg);
259  GNUNET_free (request);
260 }
int GNUNET_DNSPARSER_pack(const struct GNUNET_DNSPARSER_Packet *p, uint16_t max, char **buf, size_t *buf_length)
Given a DNS packet p, generate the corresponding UDP payload.
Definition: dnsparser.c:1257
void GNUNET_DNSPARSER_free_packet(struct GNUNET_DNSPARSER_Packet *p)
Free memory taken by a packet.
Definition: dnsparser.c:854
const void * addr
Destination address to use.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
struct GNUNET_SCHEDULER_Task * timeout_task
Task run on timeout or shutdown to clean up without response.
ssize_t GNUNET_NETWORK_socket_sendto(const struct GNUNET_NETWORK_Handle *desc, const void *message, size_t length, const struct sockaddr *dest_addr, socklen_t dest_len)
Send data to a particular destination (always non-blocking).
Definition: network.c:846
static char buf[2048]
struct GNUNET_DNSPARSER_Packet * packet
Initially, this is the DNS request, it will then be converted to the DNS response.
static unsigned int size
Size of the "table".
Definition: peer.c:67
#define GNUNET_log(kind,...)
size_t addr_len
Number of bytes in addr.
struct GNUNET_NETWORK_Handle * lsock
Socket to use for sending the reply.
static void shuffle_answers(struct Request *request)
Shuffle answers Fisher-Yates (aka Knuth) Shuffle.
char * udp_msg
Original UDP request message.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_timeout()

static void do_timeout ( void *  cls)
static

Task run on timeout.

Cleans up request.

Parameters
clsstruct Request * of the request to clean up

Definition at line 269 of file gnunet-dns2gns.c.

References Request::dns_lookup, GNUNET_DNSPARSER_free_packet(), GNUNET_DNSSTUB_resolve_cancel(), GNUNET_free, GNUNET_GNS_lookup_with_tld_cancel(), Request::lookup, Request::packet, request, and Request::udp_msg.

Referenced by dns_result_processor(), and handle_request().

270 {
271  struct Request *request = cls;
272 
273  if (NULL != request->packet)
275  if (NULL != request->lookup)
277  if (NULL != request->dns_lookup)
279  GNUNET_free (request->udp_msg);
280  GNUNET_free (request);
281 }
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:41
void * GNUNET_GNS_lookup_with_tld_cancel(struct GNUNET_GNS_LookupWithTldRequest *ltr)
Cancel pending lookup request.
Definition: gns_tld_api.c:332
void GNUNET_DNSPARSER_free_packet(struct GNUNET_DNSPARSER_Packet *p)
Free memory taken by a packet.
Definition: dnsparser.c:854
struct GNUNET_DNSPARSER_Packet * packet
Initially, this is the DNS request, it will then be converted to the DNS response.
Request we should make.
void GNUNET_DNSSTUB_resolve_cancel(struct GNUNET_DNSSTUB_RequestSocket *rs)
Cancel DNS resolution.
Definition: dnsstub.c:540
struct GNUNET_DNSSTUB_RequestSocket * dns_lookup
Our DNS request handle.
struct GNUNET_GNS_LookupWithTldRequest * lookup
Our GNS request handle.
char * udp_msg
Original UDP request message.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dns_result_processor()

static void dns_result_processor ( void *  cls,
const struct GNUNET_TUN_DnsHeader dns,
size_t  r 
)
static

Iterator called on obtained result for a DNS lookup.

Parameters
clsclosure
dnsthe DNS udp payload
rsize of the DNS payload

Definition at line 292 of file gnunet-dns2gns.c.

References _, Request::dns_lookup, do_timeout(), GNUNET_DNSPARSER_parse(), GNUNET_DNSSTUB_resolve_cancel(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_SCHEDULER_cancel(), GNUNET_TUN_DnsHeader::id, Request::original_request_id, Request::packet, request, send_response(), and Request::timeout_task.

Referenced by result_processor().

295 {
296  struct Request *request = cls;
297 
298  if (NULL == dns)
299  {
300  /* DNSSTUB gave up, so we trigger timeout early */
302  do_timeout (request);
303  return;
304  }
305  if (request->original_request_id != dns->id)
306  {
307  /* for a another query, ignore */
308  return;
309  }
310  request->packet = GNUNET_DNSPARSER_parse ((char *) dns,
311  r);
312  if (NULL == request->packet)
313  {
315  _ ("Failed to parse DNS response!\n"));
317  do_timeout (request);
318  return;
319  }
321  send_response (request);
322 }
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:41
uint16_t id
Unique identifier for the request/response.
static void send_response(struct Request *request)
Send the response for the given request and clean up.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
struct GNUNET_SCHEDULER_Task * timeout_task
Task run on timeout or shutdown to clean up without response.
struct GNUNET_DNSPARSER_Packet * GNUNET_DNSPARSER_parse(const char *udp_payload, size_t udp_payload_length)
Parse a UDP payload of a DNS packet in to a nice struct for further processing and manipulation...
Definition: dnsparser.c:656
static void do_timeout(void *cls)
Task run on timeout.
struct GNUNET_DNSPARSER_Packet * packet
Initially, this is the DNS request, it will then be converted to the DNS response.
Request we should make.
void GNUNET_DNSSTUB_resolve_cancel(struct GNUNET_DNSSTUB_RequestSocket *rs)
Cancel DNS resolution.
Definition: dnsstub.c:540
struct GNUNET_DNSSTUB_RequestSocket * dns_lookup
Our DNS request handle.
#define GNUNET_log(kind,...)
uint16_t original_request_id
ID of the original request.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
Here is the call graph for this function:
Here is the caller graph for this function:

◆ result_processor()

static void result_processor ( void *  cls,
int  was_gns,
uint32_t  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Iterator called on obtained result for a GNS lookup.

Parameters
clsclosure
was_gnsGNUNET_NO if the TLD is not configured for GNS
rd_countnumber of records in rd
rdthe records in reply

Definition at line 334 of file gnunet-dns2gns.c.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_DNSPARSER_Packet::answers, GNUNET_TUN_DnsFlags::authenticated_data, GNUNET_TUN_DnsFlags::authoritative_answer, GNUNET_TUN_DnsFlags::checking_disabled, data, GNUNET_GNSRECORD_Data::data, GNUNET_DNSPARSER_RawRecord::data, GNUNET_DNSPARSER_Record::data, GNUNET_DNSPARSER_RawRecord::data_len, GNUNET_GNSRECORD_Data::data_size, data_size, dns_ip, Request::dns_lookup, dns_result_processor(), GNUNET_DNSPARSER_Record::dns_traffic_class, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_DNSPARSER_Record::expiration_time, GNUNET_DNSPARSER_Packet::flags, GNUNET_array_append, GNUNET_assert, GNUNET_DNSPARSER_free_packet(), GNUNET_DNSPARSER_TYPE_A, GNUNET_DNSPARSER_TYPE_AAAA, GNUNET_DNSPARSER_TYPE_CNAME, GNUNET_DNSSTUB_resolve(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_strdup, GNUNET_TUN_DNS_CLASS_INTERNET, GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR, GNUNET_DNSPARSER_Record::hostname, GNUNET_DNSPARSER_Packet::id, Request::lookup, GNUNET_TUN_DnsFlags::message_truncated, GNUNET_DNSPARSER_Query::name, GNUNET_DNSPARSER_Record::name, GNUNET_DNSPARSER_Packet::num_answers, Request::original_request_id, Request::packet, GNUNET_DNSPARSER_Packet::queries, GNUNET_TUN_DnsFlags::query_or_response, GNUNET_DNSPARSER_Record::raw, GNUNET_TUN_DnsFlags::recursion_available, request, GNUNET_TUN_DnsFlags::return_code, send_response(), GNUNET_DNSPARSER_Record::type, Request::udp_msg, Request::udp_msg_size, and GNUNET_TUN_DnsFlags::zero.

Referenced by handle_request().

338 {
339  struct Request *request = cls;
340  struct GNUNET_DNSPARSER_Packet *packet;
341  struct GNUNET_DNSPARSER_Record rec;
342 
343  request->lookup = NULL;
344  if (GNUNET_NO == was_gns)
345  {
346  /* TLD not configured for GNS, fall back to DNS */
348  "Using DNS resolver IP `%s' to resolve `%s'\n",
349  dns_ip,
350  request->packet->queries[0].name);
351  request->original_request_id = request->packet->id;
353  request->packet = NULL;
355  request->udp_msg,
356  request->udp_msg_size,
358  request);
359  return;
360  }
361  packet = request->packet;
362  packet->flags.query_or_response = 1;
364  packet->flags.checking_disabled = 0;
365  packet->flags.authenticated_data = 1;
366  packet->flags.zero = 0;
367  packet->flags.recursion_available = 1;
368  packet->flags.message_truncated = 0;
369  packet->flags.authoritative_answer = 0;
370  // packet->flags.opcode = GNUNET_TUN_DNS_OPCODE_STATUS; // ???
371  for (uint32_t i = 0; i < rd_count; i++)
372  {
373  rec.expiration_time.abs_value_us = rd[i].expiration_time;
374  switch (rd[i].record_type)
375  {
377  GNUNET_assert (sizeof(struct in_addr) == rd[i].data_size);
378  rec.name = GNUNET_strdup (packet->queries[0].name);
379  rec.dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET;
380  rec.type = GNUNET_DNSPARSER_TYPE_A;
381  rec.data.raw.data = GNUNET_new (struct in_addr);
382  GNUNET_memcpy (rec.data.raw.data,
383  rd[i].data,
384  rd[i].data_size);
385  rec.data.raw.data_len = sizeof(struct in_addr);
386  GNUNET_array_append (packet->answers,
387  packet->num_answers,
388  rec);
389  break;
390 
392  GNUNET_assert (sizeof(struct in6_addr) == rd[i].data_size);
393  rec.name = GNUNET_strdup (packet->queries[0].name);
394  rec.data.raw.data = GNUNET_new (struct in6_addr);
395  rec.dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET;
396  rec.type = GNUNET_DNSPARSER_TYPE_AAAA;
397  GNUNET_memcpy (rec.data.raw.data,
398  rd[i].data,
399  rd[i].data_size);
400  rec.data.raw.data_len = sizeof(struct in6_addr);
401  GNUNET_array_append (packet->answers,
402  packet->num_answers,
403  rec);
404  break;
405 
407  rec.name = GNUNET_strdup (packet->queries[0].name);
408  rec.data.hostname = GNUNET_strdup (rd[i].data);
409  rec.dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET;
410  rec.type = GNUNET_DNSPARSER_TYPE_CNAME;
411  GNUNET_memcpy (rec.data.hostname,
412  rd[i].data,
413  rd[i].data_size);
414  GNUNET_array_append (packet->answers,
415  packet->num_answers,
416  rec);
417  break;
418 
419  default:
420  /* skip */
421  break;
422  }
423  }
424  send_response (request);
425 }
struct GNUNET_DNSPARSER_Record * answers
Array of all answers in the packet, must contain "num_answers" entries.
unsigned int zero
Always zero.
static void dns_result_processor(void *cls, const struct GNUNET_TUN_DnsHeader *dns, size_t r)
Iterator called on obtained result for a DNS lookup.
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:41
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
#define GNUNET_DNSPARSER_TYPE_CNAME
static char * dns_ip
IP of DNS server.
unsigned int return_code
See GNUNET_TUN_DNS_RETURN_CODE_ defines.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint16_t id
DNS ID (to match replies to requests).
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
void GNUNET_DNSPARSER_free_packet(struct GNUNET_DNSPARSER_Packet *p)
Free memory taken by a packet.
Definition: dnsparser.c:854
size_t data_size
Number of bytes in data.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
unsigned int recursion_available
Set to 1 if recursion is available (server -> client)
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
unsigned int num_answers
Number of answers in the packet, should be 0 for queries.
unsigned int authoritative_answer
Set to 1 if this is an authoritative answer.
static void send_response(struct Request *request)
Send the response for the given request and clean up.
unsigned int authenticated_data
Response has been cryptographically verified, RFC 4035.
unsigned int query_or_response
query:0, response:1
const void * data
Binary value stored in the DNS record.
uint64_t expiration_time
Expiration time for the DNS record.
#define GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR
RFC 1035 codes.
unsigned int message_truncated
Set to 1 if message is truncated.
A DNS response record.
struct GNUNET_DNSPARSER_Query * queries
Array of all queries in the packet, must contain "num_queries" entries.
struct GNUNET_DNSPARSER_Packet * packet
Initially, this is the DNS request, it will then be converted to the DNS response.
struct GNUNET_DNSSTUB_RequestSocket * GNUNET_DNSSTUB_resolve(struct GNUNET_DNSSTUB_Context *ctx, const void *request, size_t request_len, GNUNET_DNSSTUB_ResultCallback rc, void *rc_cls)
Perform DNS resolution using our default IP from init.
Definition: dnsstub.c:504
size_t udp_msg_size
Number of bytes in udp_msg.
#define GNUNET_TUN_DNS_CLASS_INTERNET
A few common DNS classes (ok, only one is common, but I list a couple more to make it clear what we&#39;r...
Request we should make.
#define GNUNET_DNSPARSER_TYPE_AAAA
struct GNUNET_DNSSTUB_RequestSocket * dns_lookup
Our DNS request handle.
Easy-to-process, parsed version of a DNS packet.
#define GNUNET_log(kind,...)
char * name
Name of the record that the query is for (0-terminated).
struct GNUNET_TUN_DnsFlags flags
Bitfield of DNS flags.
uint32_t data
The data value.
struct GNUNET_GNS_LookupWithTldRequest * lookup
Our GNS request handle.
struct GNUNET_DNSSTUB_Context * dns_stub
Stub resolver.
#define GNUNET_DNSPARSER_TYPE_A
char * udp_msg
Original UDP request message.
unsigned int checking_disabled
See RFC 4035.
uint16_t original_request_id
ID of the original request.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_request()

static void handle_request ( struct GNUNET_NETWORK_Handle lsock,
const void *  addr,
size_t  addr_len,
const char *  udp_msg,
size_t  udp_msg_size 
)
static

Handle DNS request.

Parameters
lsocksocket to use for sending the reply
addraddress to use for sending the reply
addr_lennumber of bytes in addr
udp_msgDNS request payload
udp_msg_sizenumber of bytes in udp_msg

Definition at line 438 of file gnunet-dns2gns.c.

References _, Request::addr, Request::addr_len, do_timeout(), GNUNET_DNSPARSER_Packet::flags, GNUNET_a2s(), GNUNET_DNSPARSER_free_packet(), GNUNET_DNSPARSER_parse(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_GNS_LO_DEFAULT, GNUNET_GNS_lookup_with_tld(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_memdup, GNUNET_SCHEDULER_add_delayed(), Request::lookup, Request::lsock, GNUNET_DNSPARSER_Query::name, GNUNET_DNSPARSER_Packet::num_additional_records, GNUNET_DNSPARSER_Packet::num_answers, GNUNET_DNSPARSER_Packet::num_authority_records, GNUNET_DNSPARSER_Packet::num_queries, Request::packet, GNUNET_DNSPARSER_Packet::queries, GNUNET_TUN_DnsFlags::query_or_response, request, result_processor(), TIMEOUT, Request::timeout_task, GNUNET_DNSPARSER_Query::type, Request::udp_msg, and Request::udp_msg_size.

Referenced by read_dns4(), and read_dns6().

443 {
444  struct Request *request;
445  struct GNUNET_DNSPARSER_Packet *packet;
446 
447  packet = GNUNET_DNSPARSER_parse (udp_msg,
448  udp_msg_size);
449  if (NULL == packet)
450  {
452  _ ("Cannot parse DNS request from %s\n"),
453  GNUNET_a2s (addr, addr_len));
454  return;
455  }
457  "Received request for `%s' with flags %u, #answers %d, #auth %d, #additional %d\n",
458  packet->queries[0].name,
459  (unsigned int) packet->flags.query_or_response,
460  (int) packet->num_answers,
461  (int) packet->num_authority_records,
462  (int) packet->num_additional_records);
463  if ((0 != packet->flags.query_or_response) ||
464  (0 != packet->num_answers) ||
465  (0 != packet->num_authority_records))
466  {
468  _ ("Received malformed DNS request from %s\n"),
469  GNUNET_a2s (addr, addr_len));
471  return;
472  }
473  if ((1 != packet->num_queries))
474  {
476  _ ("Received unsupported DNS request from %s\n"),
477  GNUNET_a2s (addr,
478  addr_len));
480  return;
481  }
482  request = GNUNET_malloc (sizeof(struct Request) + addr_len);
483  request->lsock = lsock;
484  request->packet = packet;
485  request->addr = &request[1];
486  request->addr_len = addr_len;
487  GNUNET_memcpy (&request[1],
488  addr,
489  addr_len);
490  request->udp_msg_size = udp_msg_size;
491  request->udp_msg = GNUNET_memdup (udp_msg,
492  udp_msg_size);
494  &do_timeout,
495  request);
497  "Calling GNS on `%s'\n",
498  packet->queries[0].name);
500  packet->queries[0].name,
501  packet->queries[0].type,
504  request);
505 }
uint16_t type
See GNUNET_DNSPARSER_TYPE_*.
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:41
struct GNUNET_GNS_LookupWithTldRequest * GNUNET_GNS_lookup_with_tld(struct GNUNET_GNS_Handle *handle, const char *name, uint32_t type, enum GNUNET_GNS_LocalOptions options, GNUNET_GNS_LookupResultProcessor2 proc, void *proc_cls)
Perform an asynchronous lookup operation on the GNS, determining the zone using the TLD of the given ...
Definition: gns_tld_api.c:241
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
void GNUNET_DNSPARSER_free_packet(struct GNUNET_DNSPARSER_Packet *p)
Free memory taken by a packet.
Definition: dnsparser.c:854
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.
unsigned int num_answers
Number of answers in the packet, should be 0 for queries.
static void result_processor(void *cls, int was_gns, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Iterator called on obtained result for a GNS lookup.
const void * addr
Destination address to use.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
struct GNUNET_GNS_Handle * gns
Handle to GNS resolver.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1269
#define TIMEOUT
Timeout for DNS requests.
struct GNUNET_SCHEDULER_Task * timeout_task
Task run on timeout or shutdown to clean up without response.
unsigned int query_or_response
query:0, response:1
unsigned int num_additional_records
Number of additional records in the packet, should be 0 for queries.
struct GNUNET_DNSPARSER_Packet * GNUNET_DNSPARSER_parse(const char *udp_payload, size_t udp_payload_length)
Parse a UDP payload of a DNS packet in to a nice struct for further processing and manipulation...
Definition: dnsparser.c:656
static void do_timeout(void *cls)
Task run on timeout.
const char * GNUNET_a2s(const struct sockaddr *addr, socklen_t addrlen)
Convert a "struct sockaddr*" (IPv4 or IPv6 address) to a string (for printing debug messages)...
struct GNUNET_DNSPARSER_Query * queries
Array of all queries in the packet, must contain "num_queries" entries.
struct GNUNET_DNSPARSER_Packet * packet
Initially, this is the DNS request, it will then be converted to the DNS response.
unsigned int num_authority_records
Number of authoritative answers in the packet, should be 0 for queries.
size_t udp_msg_size
Number of bytes in udp_msg.
Request we should make.
Easy-to-process, parsed version of a DNS packet.
#define GNUNET_log(kind,...)
size_t addr_len
Number of bytes in addr.
struct GNUNET_NETWORK_Handle * lsock
Socket to use for sending the reply.
char * name
Name of the record that the query is for (0-terminated).
unsigned int num_queries
Number of queries in the packet.
Defaults, look in cache, then in DHT.
struct GNUNET_TUN_DnsFlags flags
Bitfield of DNS flags.
struct GNUNET_GNS_LookupWithTldRequest * lookup
Our GNS request handle.
char * udp_msg
Original UDP request message.
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_dns4()

static void read_dns4 ( void *  cls)
static

Task to read IPv4 DNS packets.

Parameters
clsthe 'listen_socket4'

Definition at line 514 of file gnunet-dns2gns.c.

References buf, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_WARNING, GNUNET_log_strerror, GNUNET_NETWORK_socket_recvfrom(), GNUNET_NETWORK_socket_recvfrom_amount(), GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_get_task_context(), GNUNET_SCHEDULER_REASON_READ_READY, GNUNET_TIME_UNIT_FOREVER_REL, handle_request(), GNUNET_SCHEDULER_TaskContext::reason, size, and tc.

Referenced by run().

515 {
516  struct sockaddr_in v4;
517  socklen_t addrlen;
518  ssize_t size;
519  const struct GNUNET_SCHEDULER_TaskContext *tc;
520 
521  GNUNET_assert (listen_socket4 == cls);
524  &read_dns4,
528  return; /* shutdown? */
530  if (0 > size)
531  {
532  GNUNET_break (0);
533  return; /* read error!? */
534  }
535  {
536  char buf[size + 1];
537  ssize_t sret;
538 
539  addrlen = sizeof(v4);
541  buf,
542  size + 1,
543  (struct sockaddr *) &v4,
544  &addrlen);
545  if (0 > sret)
546  {
548  "recvfrom");
549  return;
550  }
551  GNUNET_break (size == sret);
553  &v4,
554  addrlen,
555  buf,
556  size);
557  }
558 }
const struct GNUNET_SCHEDULER_TaskContext * GNUNET_SCHEDULER_get_task_context(void)
Obtain the reasoning why the current task was started.
Definition: scheduler.c:752
The reading socket is ready.
Context information passed to each scheduler task.
static void read_dns4(void *cls)
Task to read IPv4 DNS packets.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:423
static struct GNUNET_NETWORK_Handle * listen_socket4
Listen socket for IPv4.
enum GNUNET_SCHEDULER_Reason reason
Reason why the task is run now.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void handle_request(struct GNUNET_NETWORK_Handle *lsock, const void *addr, size_t addr_len, const char *udp_msg, size_t udp_msg_size)
Handle DNS request.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static struct GNUNET_SCHEDULER_Task * t4
Task for IPv4 socket.
static char buf[2048]
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
static unsigned int size
Size of the "table".
Definition: peer.c:67
ssize_t GNUNET_NETWORK_socket_recvfrom_amount(const struct GNUNET_NETWORK_Handle *desc)
How much data is available to be read on this descriptor?
Definition: network.c:727
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_net(struct GNUNET_TIME_Relative delay, struct GNUNET_NETWORK_Handle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
Definition: scheduler.c:1517
ssize_t GNUNET_NETWORK_socket_recvfrom(const struct GNUNET_NETWORK_Handle *desc, void *buffer, size_t length, struct sockaddr *src_addr, socklen_t *addrlen)
Read data from a socket (always non-blocking).
Definition: network.c:754
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_dns6()

static void read_dns6 ( void *  cls)
static

Task to read IPv6 DNS packets.

Parameters
clsthe 'listen_socket6'

Definition at line 567 of file gnunet-dns2gns.c.

References buf, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_WARNING, GNUNET_log_strerror, GNUNET_NETWORK_socket_recvfrom(), GNUNET_NETWORK_socket_recvfrom_amount(), GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_get_task_context(), GNUNET_SCHEDULER_REASON_READ_READY, GNUNET_TIME_UNIT_FOREVER_REL, handle_request(), GNUNET_SCHEDULER_TaskContext::reason, size, and tc.

Referenced by run().

568 {
569  struct sockaddr_in6 v6;
570  socklen_t addrlen;
571  ssize_t size;
572  const struct GNUNET_SCHEDULER_TaskContext *tc;
573 
574  GNUNET_assert (listen_socket6 == cls);
577  &read_dns6,
581  return; /* shutdown? */
583  if (0 > size)
584  {
585  GNUNET_break (0);
586  return; /* read error!? */
587  }
588  {
589  char buf[size];
590  ssize_t sret;
591 
592  addrlen = sizeof(v6);
594  buf,
595  size,
596  (struct sockaddr *) &v6,
597  &addrlen);
598  if (0 > sret)
599  {
601  "recvfrom");
602  return;
603  }
604  GNUNET_break (size == sret);
606  &v6,
607  addrlen,
608  buf,
609  size);
610  }
611 }
const struct GNUNET_SCHEDULER_TaskContext * GNUNET_SCHEDULER_get_task_context(void)
Obtain the reasoning why the current task was started.
Definition: scheduler.c:752
static void read_dns6(void *cls)
Task to read IPv6 DNS packets.
The reading socket is ready.
Context information passed to each scheduler task.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
Definition: scheduler.c:423
enum GNUNET_SCHEDULER_Reason reason
Reason why the task is run now.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void handle_request(struct GNUNET_NETWORK_Handle *lsock, const void *addr, size_t addr_len, const char *udp_msg, size_t udp_msg_size)
Handle DNS request.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static char buf[2048]
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
static unsigned int size
Size of the "table".
Definition: peer.c:67
static struct GNUNET_NETWORK_Handle * listen_socket6
Listen socket for IPv6.
ssize_t GNUNET_NETWORK_socket_recvfrom_amount(const struct GNUNET_NETWORK_Handle *desc)
How much data is available to be read on this descriptor?
Definition: network.c:727
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_net(struct GNUNET_TIME_Relative delay, struct GNUNET_NETWORK_Handle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
Definition: scheduler.c:1517
ssize_t GNUNET_NETWORK_socket_recvfrom(const struct GNUNET_NETWORK_Handle *desc, void *buffer, size_t length, struct sockaddr *src_addr, socklen_t *addrlen)
Read data from a socket (always non-blocking).
Definition: network.c:754
static struct GNUNET_SCHEDULER_Task * t6
Task for IPv6 socket.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle c 
)
static

Main function that will be run.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cconfiguration

Definition at line 623 of file gnunet-dns2gns.c.

References _, address, address6, dns_ip, do_shutdown(), GNUNET_assert, GNUNET_CONFIGURATION_get_value_string(), GNUNET_DNSSTUB_add_dns_ip(), GNUNET_DNSSTUB_start(), GNUNET_DNSSTUB_stop(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNS_connect(), GNUNET_GNS_disconnect(), GNUNET_log, GNUNET_log_strerror, GNUNET_NETWORK_socket_bind(), GNUNET_NETWORK_socket_close(), GNUNET_NETWORK_socket_create(), GNUNET_OK, GNUNET_SCHEDULER_add_read_net(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_TIME_UNIT_FOREVER_REL, listen_port, read_dns4(), and read_dns6().

Referenced by main().

627 {
628  char *addr_str;
629 
630  (void) cls;
631  (void) args;
632  (void) cfgfile;
633  cfg = c;
634  if (NULL == dns_ip)
635  {
637  _ ("No DNS server specified!\n"));
638  return;
639  }
641  NULL);
642  if (NULL == (gns = GNUNET_GNS_connect (cfg)))
643  return;
644  GNUNET_assert (NULL != (dns_stub = GNUNET_DNSSTUB_start (128)));
645  if (GNUNET_OK !=
647  dns_ip))
648  {
651  gns = NULL;
652  return;
653  }
654 
655  /* Get address to bind to */
657  "BIND_TO",
658  &addr_str))
659  {
660  // No address specified
662  "Don't know what to bind to...\n");
663  GNUNET_free (addr_str);
665  return;
666  }
667  if (1 != inet_pton (AF_INET, addr_str, &address))
668  {
670  "Unable to parse address %s\n",
671  addr_str);
672  GNUNET_free (addr_str);
674  return;
675  }
676  GNUNET_free (addr_str);
677  /* Get address to bind to */
679  "BIND_TO6",
680  &addr_str))
681  {
682  // No address specified
684  "Don't know what to bind6 to...\n");
685  GNUNET_free (addr_str);
687  return;
688  }
689  if (1 != inet_pton (AF_INET6, addr_str, &address6))
690  {
692  "Unable to parse IPv6 address %s\n",
693  addr_str);
694  GNUNET_free (addr_str);
696  return;
697  }
698  GNUNET_free (addr_str);
699 
701  SOCK_DGRAM,
702  IPPROTO_UDP);
703  if (NULL != listen_socket4)
704  {
705  struct sockaddr_in v4;
706 
707  memset (&v4, 0, sizeof(v4));
708  v4.sin_family = AF_INET;
709  v4.sin_addr.s_addr = address;
710 #if HAVE_SOCKADDR_IN_SIN_LEN
711  v4.sin_len = sizeof(v4);
712 #endif
713  v4.sin_port = htons (listen_port);
714  if (GNUNET_OK !=
716  (struct sockaddr *) &v4,
717  sizeof(v4)))
718  {
721  listen_socket4 = NULL;
722  }
723  }
725  SOCK_DGRAM,
726  IPPROTO_UDP);
727  if (NULL != listen_socket6)
728  {
729  struct sockaddr_in6 v6;
730 
731  memset (&v6, 0, sizeof(v6));
732  v6.sin6_family = AF_INET6;
733  v6.sin6_addr = address6;
734 #if HAVE_SOCKADDR_IN_SIN_LEN
735  v6.sin6_len = sizeof(v6);
736 #endif
737  v6.sin6_port = htons (listen_port);
738  if (GNUNET_OK !=
740  (struct sockaddr *) &v6,
741  sizeof(v6)))
742  {
745  listen_socket6 = NULL;
746  }
747  }
748  if ((NULL == listen_socket4) &&
749  (NULL == listen_socket6))
750  {
752  gns = NULL;
754  dns_stub = NULL;
755  return;
756  }
757  if (NULL != listen_socket4)
760  &read_dns4,
762  if (NULL != listen_socket6)
765  &read_dns6,
767 }
static unsigned int listen_port
UDP Port we listen on for inbound DNS requests.
static void read_dns6(void *cls)
Task to read IPv6 DNS packets.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1331
static char * dns_ip
IP of DNS server.
static void read_dns4(void *cls)
Task to read IPv4 DNS packets.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_DNSSTUB_stop(struct GNUNET_DNSSTUB_Context *ctx)
Cleanup DNSSTUB resolver.
Definition: dnsstub.c:690
int GNUNET_DNSSTUB_add_dns_ip(struct GNUNET_DNSSTUB_Context *ctx, const char *dns_ip)
Add nameserver for use by the DNSSTUB.
Definition: dnsstub.c:591
int GNUNET_NETWORK_socket_bind(struct GNUNET_NETWORK_Handle *desc, const struct sockaddr *address, socklen_t address_len)
Bind a socket to a particular address.
Definition: network.c:485
static struct GNUNET_NETWORK_Handle * listen_socket4
Listen socket for IPv4.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
struct GNUNET_GNS_Handle * gns
Handle to GNS resolver.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
static in_addr_t address
The address to bind to.
struct GNUNET_DNSSTUB_Context * GNUNET_DNSSTUB_start(unsigned int num_sockets)
Start a DNS stub resolver.
Definition: dnsstub.c:564
static struct GNUNET_SCHEDULER_Task * t4
Task for IPv4 socket.
void GNUNET_GNS_disconnect(struct GNUNET_GNS_Handle *handle)
Shutdown connection with the GNS service.
Definition: gns_api.c:290
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_GNS_Handle * GNUNET_GNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the GNS service.
Definition: gns_api.c:268
static void do_shutdown(void *cls)
Task run on shutdown.
#define GNUNET_log(kind,...)
static struct GNUNET_NETWORK_Handle * listen_socket6
Listen socket for IPv6.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_net(struct GNUNET_TIME_Relative delay, struct GNUNET_NETWORK_Handle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
Definition: scheduler.c:1517
struct GNUNET_DNSSTUB_Context * dns_stub
Stub resolver.
int GNUNET_NETWORK_socket_close(struct GNUNET_NETWORK_Handle *desc)
Close a socket.
Definition: network.c:560
#define GNUNET_free(ptr)
Wrapper around free.
static struct GNUNET_SCHEDULER_Task * t6
Task for IPv6 socket.
static struct in6_addr address6
The IPv6 address to bind to.
struct GNUNET_NETWORK_Handle * GNUNET_NETWORK_socket_create(int domain, int type, int protocol)
Create a new socket.
Definition: network.c:909
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

The main function for the dns2gns daemon.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 778 of file gnunet-dns2gns.c.

References _, dns_ip, gettext_noop, GNUNET_free_nz, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_string(), GNUNET_GETOPT_option_uint(), GNUNET_log_setup(), GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), listen_port, ret, and run().

780 {
783  "dns",
784  "IP",
785  gettext_noop (
786  "IP of recursive DNS resolver to use (required)"),
787  &dns_ip),
789  "port",
790  "UDPPORT",
791  gettext_noop (
792  "UDP port to listen on for inbound DNS requests; default: 2853"),
793  &listen_port),
795  };
796  int ret;
797 
798  if (GNUNET_OK !=
799  GNUNET_STRINGS_get_utf8_args (argc, argv,
800  &argc, &argv))
801  return 2;
802  GNUNET_log_setup ("gnunet-dns2gns",
803  "WARNING",
804  NULL);
805  ret =
806  (GNUNET_OK ==
807  GNUNET_PROGRAM_run (argc, argv,
808  "gnunet-dns2gns",
809  _ ("GNUnet DNS-to-GNS proxy (a DNS server)"),
810  options,
811  &run, NULL)) ? 0 : 1;
812  GNUNET_free_nz ((void *) argv);
813  return ret;
814 }
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:363
static unsigned int listen_port
UDP Port we listen on for inbound DNS requests.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static char * dns_ip
IP of DNS server.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1459
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
Definition of a command line option.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
#define GNUNET_free_nz(ptr)
Wrapper around free.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

Variable Documentation

◆ address

in_addr_t address
static

The address to bind to.

Definition at line 98 of file gnunet-dns2gns.c.

Referenced by run().

◆ address6

struct in6_addr address6
static

The IPv6 address to bind to.

Definition at line 103 of file gnunet-dns2gns.c.

Referenced by run().

◆ gns

struct GNUNET_GNS_Handle* gns

Handle to GNS resolver.

Definition at line 109 of file gnunet-dns2gns.c.

◆ dns_stub

struct GNUNET_DNSSTUB_Context* dns_stub

Stub resolver.

Definition at line 114 of file gnunet-dns2gns.c.

◆ listen_socket4

struct GNUNET_NETWORK_Handle* listen_socket4
static

Listen socket for IPv4.

Definition at line 119 of file gnunet-dns2gns.c.

◆ listen_socket6

struct GNUNET_NETWORK_Handle* listen_socket6
static

Listen socket for IPv6.

Definition at line 124 of file gnunet-dns2gns.c.

◆ t4

struct GNUNET_SCHEDULER_Task* t4
static

◆ t6

struct GNUNET_SCHEDULER_Task* t6
static

◆ dns_ip

char* dns_ip
static

IP of DNS server.

Definition at line 139 of file gnunet-dns2gns.c.

Referenced by main(), result_processor(), and run().

◆ listen_port

unsigned int listen_port = 53
static

UDP Port we listen on for inbound DNS requests.

Definition at line 144 of file gnunet-dns2gns.c.

Referenced by main(), and run().

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Configuration to use.

Definition at line 149 of file gnunet-dns2gns.c.