/*
This file is part of GNUnet.
- (C) 2001-2014 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2001-2014 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.
*/
/**
#include "gnunet-peerinfo_plugins.h"
/**
- * How long until we time out during peerinfo iterations?
+ * How long until we time out during address lookup?
*/
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
/**
* Main state machine task (if active).
*/
-static GNUNET_SCHEDULER_TaskIdentifier tt;
+static struct GNUNET_SCHEDULER_Task * tt;
/**
* Pending #GNUNET_TRANSPORT_get_hello() operation.
/**
* Handle to current #GNUNET_PEERINFO_add_peer() operation.
*/
-static struct GNUNET_PEERINFO_AddContext *ac;
+static struct GNUNET_MQ_Envelope *ac;
/**
* Hello of this peer (if initialized).
* runs the next requested function.
*
* @param cls unused
- * @param tc unused
*/
static void
-state_machine (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc);
+state_machine (void *cls);
/* ********************* 'get_info' ******************* */
if (NULL != address)
{
- if (NULL == ar->result)
+ if (0 != strlen (address))
+ {
+ if (NULL != ar->result)
+ GNUNET_free (ar->result);
ar->result = GNUNET_strdup (address);
+ }
return;
}
ar->atsc = NULL;
if (GNUNET_SYSERR == res)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Failure: Cannot convert address to string for peer `%s'\n"),
- GNUNET_i2s (&ar->pc->peer));
+ _("Failure: Cannot convert address to string for peer `%s'\n"),
+ GNUNET_i2s (&ar->pc->peer));
pc->num_addresses++;
if (pc->num_addresses == pc->address_list_size)
dump_pc (pc);
ar = &pc->address_list[--pc->off];
ar->pc = pc;
ar->expiration = expiration;
+ GNUNET_asprintf (&ar->result,
+ "%s:%u:%u",
+ address->transport_name,
+ address->address_length,
+ address->local_info);
ar->atsc = GNUNET_TRANSPORT_address_to_string (cfg,
address,
no_resolve,
* Continuation called from #GNUNET_PEERINFO_add_peer()
*
* @param cls closure, NULL
- * @param emsg error message, NULL on success
*/
static void
-add_continuation (void *cls,
- const char *emsg)
+add_continuation (void *cls)
{
ac = NULL;
- if (NULL != emsg)
- fprintf (stderr,
- _("Failure adding HELLO: %s\n"),
- emsg);
tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
}
{
/* WARNING: this adds the address from URI WITHOUT verification! */
if (GNUNET_OK == ret)
- ac = GNUNET_PEERINFO_add_peer (peerinfo, hello,
+ ac = GNUNET_PEERINFO_add_peer (peerinfo,
+ hello,
&add_continuation,
NULL);
else
* runs the next requested function.
*
* @param cls unused
- * @param tc scheduler context
*/
static void
-shutdown_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls)
{
struct PrintContext *pc;
struct AddressRecord *ar;
if (NULL != ac)
{
- GNUNET_PEERINFO_add_peer_cancel (ac);
+ GNUNET_MQ_send_cancel (ac);
ac = NULL;
}
- if (GNUNET_SCHEDULER_NO_TASK != tt)
+ if (NULL != tt)
{
GNUNET_SCHEDULER_cancel (tt);
- tt = GNUNET_SCHEDULER_NO_TASK;
+ tt = NULL;
}
if (NULL != pic)
{
}
my_hello = (struct GNUNET_HELLO_Message *) GNUNET_copy_message (hello);
GNUNET_assert (GNUNET_OK ==
- GNUNET_HELLO_get_id (hello,
+ GNUNET_HELLO_get_id (my_hello,
&my_peer_identity));
GNUNET_TRANSPORT_get_hello_cancel (gh);
gh = NULL;
{
tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
}
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
- &shutdown_task,
- NULL);
+ GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+ NULL);
}
* runs the next requested function.
*
* @param cls unused
- * @param tc scheduler context
*/
static void
-state_machine (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+state_machine (void *cls)
{
- tt = GNUNET_SCHEDULER_NO_TASK;
+ tt = NULL;
if (NULL != put_uri)
{
pic = GNUNET_PEERINFO_iterate (peerinfo,
include_friend_only,
NULL,
- TIMEOUT,
&print_peer_info, NULL);
}
else if (GNUNET_YES == get_self)
pic = GNUNET_PEERINFO_iterate (peerinfo,
include_friend_only,
&my_peer_identity,
- TIMEOUT,
&print_my_uri, NULL);
get_uri = GNUNET_NO;
}