/*
This file is part of GNUnet.
- (C) 2012 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2012 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
* @file dns/dnsstub.c
GNUNET_DNSSTUB_ResultCallback rc;
/**
- * Closure for 'rc'.
+ * Closure for @e rc.
*/
void *rc_cls;
/**
* Task for reading from dnsout4 and dnsout6.
*/
- GNUNET_SCHEDULER_TaskIdentifier read_task;
+ struct GNUNET_SCHEDULER_Task * read_task;
/**
* When should this request time out?
struct sockaddr_storage addr;
/**
- * Number of bytes in 'addr'.
+ * Number of bytes in @e addr.
*/
socklen_t addrlen;
/**
* IP address to use for the DNS server if we are a DNS exit service
- * (for VPN via mesh); otherwise NULL.
+ * (for VPN via cadet); otherwise NULL.
*/
char *dns_exit;
};
/**
- * We're done with a GNUNET_DNSSTUB_RequestSocket, close it for now.
+ * We're done with a `struct GNUNET_DNSSTUB_RequestSocket`, close it for now.
*
* @param rs request socket to clean up
*/
GNUNET_NETWORK_socket_close (rs->dnsout6);
rs->dnsout6 = NULL;
}
- if (GNUNET_SCHEDULER_NO_TASK != rs->read_task)
+ if (NULL != rs->read_task)
{
GNUNET_SCHEDULER_cancel (rs->read_task);
- rs->read_task = GNUNET_SCHEDULER_NO_TASK;
+ rs->read_task = NULL;
}
}
* Open source port for sending DNS requests
*
* @param af AF_INET or AF_INET6
- * @return GNUNET_OK on success
+ * @return #GNUNET_OK on success
*/
static struct GNUNET_NETWORK_Handle *
open_socket (int af)
* Read a DNS response from the (unhindered) UDP-Socket
*
* @param cls socket to read from
- * @param tc scheduler context (must be shutdown or read ready)
*/
static void
-read_response (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc);
+read_response (void *cls);
/**
default:
return NULL;
}
- if (GNUNET_SCHEDULER_NO_TASK != rs->read_task)
+ if (NULL != rs->read_task)
{
GNUNET_SCHEDULER_cancel (rs->read_task);
- rs->read_task = GNUNET_SCHEDULER_NO_TASK;
+ rs->read_task = NULL;
}
if ( (NULL == rs->dnsout4) &&
(NULL == rs->dnsout6) )
*
* @param rs request socket with callback details
* @param dnsout socket to read from
- * @return GNUNET_OK on success, GNUNET_NO on drop, GNUNET_SYSERR on IO-errors (closed socket)
+ * @return #GNUNET_OK on success, #GNUNET_NO on drop, #GNUNET_SYSERR on IO-errors (closed socket)
*/
static int
do_dns_read (struct GNUNET_DNSSTUB_RequestSocket *rs,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Received DNS response that is too small (%u bytes)"),
- r);
+ (unsigned int) r);
return GNUNET_NO;
}
dns = (struct GNUNET_TUN_DnsHeader *) buf;
* Read a DNS response from the (unhindered) UDP-Socket
*
* @param cls socket to read from
- * @param tc scheduler context (must be shutdown or read ready)
*/
static void
-read_response (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+read_response (void *cls)
{
struct GNUNET_DNSSTUB_RequestSocket *rs = cls;
struct GNUNET_NETWORK_FDSet *rset;
+ const struct GNUNET_SCHEDULER_TaskContext *tc;
- rs->read_task = GNUNET_SCHEDULER_NO_TASK;
+ rs->read_task = NULL;
+ tc = GNUNET_SCHEDULER_get_task_context ();
if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY))
{
- /* timeout or shutdown */
+ /* timeout */
cleanup_rs (rs);
return;
}
{
struct GNUNET_DNSSTUB_Context *ctx;
- ctx = GNUNET_malloc (sizeof (struct GNUNET_DNSSTUB_Context));
+ ctx = GNUNET_new (struct GNUNET_DNSSTUB_Context);
if (NULL != dns_ip)
ctx->dns_exit = GNUNET_strdup (dns_ip);
return ctx;