#include "gnunet_time_lib.h"
#include "gnunet_util_lib.h"
+#define DEBUG_HOSTLIST_LEARNING GNUNET_YES
+#define VERBOSE GNUNET_YES
/**
* Set if we are allowed to advertise our hostlist to others.
}
}
+/**
+ * Core handler for p2p hostlist advertisements
+ */
+static int handle_hostlist_advertisement (void *cls,
+ const struct GNUNET_PeerIdentity * peer,
+ const struct GNUNET_MessageHeader * message,
+ struct GNUNET_TIME_Relative latency,
+ uint32_t distance)
+{
+#if DEBUG_HOSTLIST_LEARNING
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Recieved hostlist advertisement\n"));
+#endif
+
+ return GNUNET_OK;
+}
/**
* Last task run during shutdown. Disconnects us from
cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Hostlist daemon is shutting down.\n");
+ "Hostlist daemon is shutting down\n");
if (bootstrapping)
{
GNUNET_HOSTLIST_client_stop ();
}
}
+/**
+ * List of handlers for the messages understood by this
+ * service.
+ */
+static struct GNUNET_CORE_MessageHandler handlers[] = {
+ { &handle_hostlist_advertisement, GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT, 0},
+ { NULL, 0, 0 }
+};
/**
* Main function that will be run.
{
GNUNET_CORE_ConnectEventHandler ch = NULL;
GNUNET_CORE_DisconnectEventHandler dh = NULL;
- struct GNUNET_CORE_MessageHandler handlers[] =
- {
+
+
+
+ struct GNUNET_CORE_MessageHandler null_handler[] = {
{ NULL, 0, 0 }
- };
+ };
+
+ struct GNUNET_CORE_MessageHandler *used_handler = null_handler;
if ( (! bootstrapping) &&
(! learning) &&
}
if (learning)
{
- /* FIXME (register handler with core for hostlist ads) */
+ used_handler = handlers;
}
+
core = GNUNET_CORE_connect (sched, cfg,
- GNUNET_TIME_UNIT_FOREVER_REL,
- NULL,
- &core_init,
- NULL, ch, dh,
- NULL, GNUNET_NO,
- NULL, GNUNET_NO,
- handlers);
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ NULL,
+ &core_init,
+ NULL, ch, dh,
+ NULL, GNUNET_NO,
+ NULL, GNUNET_NO,
+ used_handler);
+
GNUNET_SCHEDULER_add_delayed (sched,
GNUNET_TIME_UNIT_FOREVER_REL,
&cleaning_task, NULL);
main (int argc, char *const *argv)
{
int ret;
+ GNUNET_log_setup ("hostlist","DEBUG",NULL);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "ERROR\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DEBUG\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "INFO\n");
ret = (GNUNET_OK ==
GNUNET_PROGRAM_run (argc,
_("GNUnet hostlist server and client"),
options,
&run, NULL)) ? 0 : 1;
+
return ret;
}