/*
This file is part of GNUnet.
- Copyright (C) 2012-2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2012-2013 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
* Task run on shutdown. Cleans up everything.
*
* @param cls unused
- * @param tc scheduler context
*/
static void
-do_shutdown (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_shutdown (void *cls)
{
if (NULL != t4)
+ {
GNUNET_SCHEDULER_cancel (t4);
+ t4 = NULL;
+ }
if (NULL != t6)
+ {
GNUNET_SCHEDULER_cancel (t6);
+ t6 = NULL;
+ }
if (NULL != listen_socket4)
{
GNUNET_NETWORK_socket_close (listen_socket4);
/**
* Task run on timeout. Cleans up request.
*
- * @param cls 'struct Request' of the request to clean up
- * @param tc scheduler context
+ * @param cls `struct Request *` of the request to clean up
*/
static void
-do_timeout (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_timeout (void *cls)
{
struct Request *request = cls;
* Task to read IPv4 DNS packets.
*
* @param cls the 'listen_socket4'
- * @param tc scheduler context
*/
static void
-read_dns4 (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+read_dns4 (void *cls)
{
struct sockaddr_in v4;
socklen_t addrlen;
ssize_t size;
+ const struct GNUNET_SCHEDULER_TaskContext *tc;
GNUNET_assert (listen_socket4 == cls);
t4 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
listen_socket4,
&read_dns4,
listen_socket4);
+ tc = GNUNET_SCHEDULER_get_task_context ();
if (0 == (GNUNET_SCHEDULER_REASON_READ_READY & tc->reason))
return; /* shutdown? */
size = GNUNET_NETWORK_socket_recvfrom_amount (listen_socket4);
* Task to read IPv6 DNS packets.
*
* @param cls the 'listen_socket6'
- * @param tc scheduler context
*/
static void
-read_dns6 (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+read_dns6 (void *cls)
{
struct sockaddr_in6 v6;
socklen_t addrlen;
ssize_t size;
+ const struct GNUNET_SCHEDULER_TaskContext *tc;
GNUNET_assert (listen_socket6 == cls);
t6 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
listen_socket6,
&read_dns6,
listen_socket6);
+ tc = GNUNET_SCHEDULER_get_task_context ();
if (0 == (GNUNET_SCHEDULER_REASON_READ_READY & tc->reason))
return; /* shutdown? */
size = GNUNET_NETWORK_socket_recvfrom_amount (listen_socket6);
SOCK_DGRAM,
IPPROTO_UDP);
if (NULL != listen_socket4)
- {
- struct sockaddr_in v4;
-
- memset (&v4, 0, sizeof (v4));
- v4.sin_family = AF_INET;
+ {
+ struct sockaddr_in v4;
+
+ memset (&v4, 0, sizeof (v4));
+ v4.sin_family = AF_INET;
#if HAVE_SOCKADDR_IN_SIN_LEN
- v4.sin_len = sizeof (v4);
+ v4.sin_len = sizeof (v4);
#endif
- v4.sin_port = htons (listen_port);
- if (GNUNET_OK !=
- GNUNET_NETWORK_socket_bind (listen_socket4,
- (struct sockaddr *) &v4,
- sizeof (v4)))
- {
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind");
- GNUNET_NETWORK_socket_close (listen_socket4);
- listen_socket4 = NULL;
- }
+ v4.sin_port = htons (listen_port);
+ if (GNUNET_OK !=
+ GNUNET_NETWORK_socket_bind (listen_socket4,
+ (struct sockaddr *) &v4,
+ sizeof (v4)))
+ {
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind");
+ GNUNET_NETWORK_socket_close (listen_socket4);
+ listen_socket4 = NULL;
}
+ }
listen_socket6 = GNUNET_NETWORK_socket_create (PF_INET6,
SOCK_DGRAM,
IPPROTO_UDP);
if (NULL != listen_socket6)
- {
- struct sockaddr_in6 v6;
-
- memset (&v6, 0, sizeof (v6));
- v6.sin6_family = AF_INET6;
+ {
+ struct sockaddr_in6 v6;
+
+ memset (&v6, 0, sizeof (v6));
+ v6.sin6_family = AF_INET6;
#if HAVE_SOCKADDR_IN_SIN_LEN
- v6.sin6_len = sizeof (v6);
+ v6.sin6_len = sizeof (v6);
#endif
- v6.sin6_port = htons (listen_port);
- if (GNUNET_OK !=
- GNUNET_NETWORK_socket_bind (listen_socket6,
- (struct sockaddr *) &v6,
- sizeof (v6)))
- {
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind");
- GNUNET_NETWORK_socket_close (listen_socket6);
- listen_socket6 = NULL;
- }
+ v6.sin6_port = htons (listen_port);
+ if (GNUNET_OK !=
+ GNUNET_NETWORK_socket_bind (listen_socket6,
+ (struct sockaddr *) &v6,
+ sizeof (v6)))
+ {
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind");
+ GNUNET_NETWORK_socket_close (listen_socket6);
+ listen_socket6 = NULL;
}
+ }
if ( (NULL == listen_socket4) &&
(NULL == listen_socket6) )
- {
- GNUNET_GNS_disconnect (gns);
- gns = NULL;
- GNUNET_DNSSTUB_stop (dns_stub);
- dns_stub = NULL;
- return;
- }
+ {
+ GNUNET_GNS_disconnect (gns);
+ gns = NULL;
+ GNUNET_DNSSTUB_stop (dns_stub);
+ dns_stub = NULL;
+ return;
+ }
if (NULL != listen_socket4)
t4 = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
listen_socket4,
listen_socket6,
&read_dns6,
listen_socket6);
-
}
* @param c configuration
*/
static void
-run (void *cls, char *const *args, const char *cfgfile,
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *c)
{
cfg = c;
_("No DNS server specified!\n"));
return;
}
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &do_shutdown, NULL);
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
if (NULL == gns_zone_str)
{
identity = GNUNET_IDENTITY_connect (cfg,
if ( (NULL == gns_zone_str) ||
(GNUNET_OK !=
GNUNET_CRYPTO_ecdsa_public_key_from_string (gns_zone_str,
- strlen (gns_zone_str),
- &my_zone)) )
+ strlen (gns_zone_str),
+ &my_zone)) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("No valid GNS zone specified!\n"));
gettext_noop ("Authoritative DNS suffix to use (optional); default: zkey.eu"), 1,
&GNUNET_GETOPT_set_string, &dns_suffix},
{'p', "port", "UDPPORT",
- gettext_noop ("UDP port to listen on for inbound DNS requests; default: 53"), 1,
+ gettext_noop ("UDP port to listen on for inbound DNS requests; default: 2853"), 1,
&GNUNET_GETOPT_set_uint, &listen_port},
{'z', "zone", "PUBLICKEY",
gettext_noop ("Public key of the GNS zone to use (overrides default)"), 1,