aboutsummaryrefslogtreecommitdiff
path: root/src/hostlist/hostlist-client.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-04-08 13:06:54 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-04-08 13:06:54 +0000
commit967a3bbae2c2a7c6fe5c975f1ba6cdbbd17d183f (patch)
treebf7a9af6761b62d3e8abfc95469d470547fb93cc /src/hostlist/hostlist-client.c
parente8757f03baa17eddef096da91122a282a39e9cb7 (diff)
downloadgnunet-967a3bbae2c2a7c6fe5c975f1ba6cdbbd17d183f.tar.gz
gnunet-967a3bbae2c2a7c6fe5c975f1ba6cdbbd17d183f.zip
hostlist client gets notified when hostlist advertisments arrive
Diffstat (limited to 'src/hostlist/hostlist-client.c')
-rw-r--r--src/hostlist/hostlist-client.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c
index 1c0deb511..3824972d8 100644
--- a/src/hostlist/hostlist-client.c
+++ b/src/hostlist/hostlist-client.c
@@ -32,7 +32,7 @@
32#include "gnunet_transport_service.h" 32#include "gnunet_transport_service.h"
33#include <curl/curl.h> 33#include <curl/curl.h>
34 34
35#define DEBUG_HOSTLIST_CLIENT GNUNET_NO 35#define DEBUG_HOSTLIST_CLIENT GNUNET_YES
36 36
37/** 37/**
38 * Number of connections that we must have to NOT download 38 * Number of connections that we must have to NOT download
@@ -695,7 +695,7 @@ connect_handler (void *cls,
695 695
696 696
697/** 697/**
698 * Method called whenever a given peer connects. 698 * Method called whenever a given peer disconnects.
699 * 699 *
700 * @param cls closure 700 * @param cls closure
701 * @param peer peer identity this notification is about 701 * @param peer peer identity this notification is about
@@ -712,6 +712,31 @@ disconnect_handler (void *cls,
712 GNUNET_NO); 712 GNUNET_NO);
713} 713}
714 714
715/**
716 * Method called whenever an advertisement message arrives.
717 *
718 * @param cls closure (always NULL)
719 * @param client identification of the client
720 * @param message the actual message
721 * @return GNUNET_OK to keep the connection open,
722 * GNUNET_SYSERR to close it (signal serious error)
723 */
724static int
725advertisement_handler (void *cls,
726 const struct GNUNET_PeerIdentity * peer,
727 const struct GNUNET_MessageHeader * message,
728 struct GNUNET_TIME_Relative latency,
729 uint32_t distance)
730{
731#if DEBUG_HOSTLIST_CLIENT
732 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
733 "Hostlist client recieved advertisement message\n");
734#endif
735
736 /* put code to use message here */
737
738 return GNUNET_YES;
739}
715 740
716/** 741/**
717 * Continuation called by the statistics code once 742 * Continuation called by the statistics code once
@@ -757,7 +782,8 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
757 struct GNUNET_SCHEDULER_Handle *s, 782 struct GNUNET_SCHEDULER_Handle *s,
758 struct GNUNET_STATISTICS_Handle *st, 783 struct GNUNET_STATISTICS_Handle *st,
759 GNUNET_CORE_ConnectEventHandler *ch, 784 GNUNET_CORE_ConnectEventHandler *ch,
760 GNUNET_CORE_DisconnectEventHandler *dh) 785 GNUNET_CORE_DisconnectEventHandler *dh,
786 GNUNET_CORE_MessageCallback *msgh)
761{ 787{
762 if (0 != curl_global_init (CURL_GLOBAL_WIN32)) 788 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
763 { 789 {
@@ -781,6 +807,7 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
781 proxy = NULL; 807 proxy = NULL;
782 *ch = &connect_handler; 808 *ch = &connect_handler;
783 *dh = &disconnect_handler; 809 *dh = &disconnect_handler;
810 *msgh = &advertisement_handler;
784 GNUNET_STATISTICS_get (stats, 811 GNUNET_STATISTICS_get (stats,
785 "hostlist", 812 "hostlist",
786 gettext_noop("Minimum time between hostlist downloads"), 813 gettext_noop("Minimum time between hostlist downloads"),