aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-06-30 13:21:19 +0000
committerNathan S. Evans <evans@in.tum.de>2010-06-30 13:21:19 +0000
commitf5eaab80bfdbe04703096554f442dcbfa970b745 (patch)
tree31559f26ba20d6a2cf63b85973985841ce65ba78 /src/dht/gnunet-service-dht.c
parentd5d4f7845deb59deeb7a7664cbd78b3c09601b59 (diff)
downloadgnunet-f5eaab80bfdbe04703096554f442dcbfa970b745.tar.gz
gnunet-f5eaab80bfdbe04703096554f442dcbfa970b745.zip
twopeer dht test, mostly for class
Diffstat (limited to 'src/dht/gnunet-service-dht.c')
-rw-r--r--src/dht/gnunet-service-dht.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index 8c7e66920..a2e0f4db7 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -70,6 +70,11 @@ static struct GNUNET_TRANSPORT_Handle *transport_handle;
70static struct GNUNET_PeerIdentity my_identity; 70static struct GNUNET_PeerIdentity my_identity;
71 71
72/** 72/**
73 * Short id of the peer, for printing
74 */
75static char *my_short_id;
76
77/**
73 * Our HELLO 78 * Our HELLO
74 */ 79 */
75static struct GNUNET_MessageHeader *my_hello; 80static struct GNUNET_MessageHeader *my_hello;
@@ -704,6 +709,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
704 GNUNET_CORE_disconnect (coreAPI); 709 GNUNET_CORE_disconnect (coreAPI);
705 if (datacache != NULL) 710 if (datacache != NULL)
706 GNUNET_DATACACHE_destroy (datacache); 711 GNUNET_DATACACHE_destroy (datacache);
712 if (my_short_id != NULL)
713 GNUNET_free(my_short_id);
707} 714}
708 715
709 716
@@ -740,6 +747,7 @@ core_init (void *cls,
740#endif 747#endif
741 /* Copy our identity so we can use it */ 748 /* Copy our identity so we can use it */
742 memcpy (&my_identity, identity, sizeof (struct GNUNET_PeerIdentity)); 749 memcpy (&my_identity, identity, sizeof (struct GNUNET_PeerIdentity));
750 my_short_id = GNUNET_strdup(GNUNET_i2s(&my_identity));
743 /* Set the server to local variable */ 751 /* Set the server to local variable */
744 coreAPI = server; 752 coreAPI = server;
745} 753}
@@ -758,6 +766,24 @@ static struct GNUNET_CORE_MessageHandler core_handlers[] = {
758 {NULL, 0, 0} 766 {NULL, 0, 0}
759}; 767};
760 768
769/**
770 * Method called whenever a peer connects.
771 *
772 * @param cls closure
773 * @param peer peer identity this notification is about
774 * @param latency reported latency of the connection with peer
775 * @param distance reported distance (DV) to peer
776 */
777void handle_core_connect (void *cls,
778 const struct GNUNET_PeerIdentity * peer,
779 struct GNUNET_TIME_Relative latency,
780 uint32_t distance)
781{
782#if DEBUG_DHT
783 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
784 "%s:%s Receives core connect message for peer %s distance %d!\n", my_short_id, "dht", GNUNET_i2s(peer), distance);
785#endif
786}
761 787
762/** 788/**
763 * Process dht requests. 789 * Process dht requests.
@@ -782,7 +808,7 @@ run (void *cls,
782 GNUNET_TIME_UNIT_FOREVER_REL, 808 GNUNET_TIME_UNIT_FOREVER_REL,
783 NULL, /* FIXME: anything we want to pass around? */ 809 NULL, /* FIXME: anything we want to pass around? */
784 &core_init, /* Call core_init once connected */ 810 &core_init, /* Call core_init once connected */
785 NULL, /* Don't care about connects */ 811 &handle_core_connect, /* Don't care about connects */
786 NULL, /* Don't care about disconnects */ 812 NULL, /* Don't care about disconnects */
787 NULL, /* Don't want notified about all incoming messages */ 813 NULL, /* Don't want notified about all incoming messages */
788 GNUNET_NO, /* For header only inbound notification */ 814 GNUNET_NO, /* For header only inbound notification */
@@ -802,7 +828,6 @@ run (void *cls,
802 &shutdown_task, NULL); 828 &shutdown_task, NULL);
803} 829}
804 830
805
806/** 831/**
807 * The main function for the dht service. 832 * The main function for the dht service.
808 * 833 *