aboutsummaryrefslogtreecommitdiff
path: root/src/dv
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-06-24 11:03:11 +0000
committerNathan S. Evans <evans@in.tum.de>2010-06-24 11:03:11 +0000
commit76259023a5566d42229a4a284616fa8bac93b6a5 (patch)
tree1bfe89a5a7ed226ba05e41e7fcbb369b98eec2d9 /src/dv
parent551e4e177a8623ac35ece7125ec07de5f9b9d294 (diff)
downloadgnunet-76259023a5566d42229a4a284616fa8bac93b6a5.tar.gz
gnunet-76259023a5566d42229a4a284616fa8bac93b6a5.zip
misc bugfixes, especially core dumps for dv test case
Diffstat (limited to 'src/dv')
-rw-r--r--src/dv/dv.h14
-rw-r--r--src/dv/dv_api.c56
-rw-r--r--src/dv/gnunet-service-dv.c6
-rw-r--r--src/dv/plugin_transport_dv.c25
-rw-r--r--src/dv/test_transport_api_dv.c17
-rw-r--r--src/dv/test_transport_dv_data.conf14
6 files changed, 70 insertions, 62 deletions
diff --git a/src/dv/dv.h b/src/dv/dv.h
index 28a56031e..7b32d7d14 100644
--- a/src/dv/dv.h
+++ b/src/dv/dv.h
@@ -31,7 +31,7 @@
31#define DEBUG_DV_GOSSIP GNUNET_NO 31#define DEBUG_DV_GOSSIP GNUNET_NO
32#define DEBUG_DV_GOSSIP_SEND GNUNET_NO 32#define DEBUG_DV_GOSSIP_SEND GNUNET_NO
33#define DEBUG_DV_GOSSIP_RECEIPT GNUNET_NO 33#define DEBUG_DV_GOSSIP_RECEIPT GNUNET_NO
34#define DEBUG_DV_MESSAGES GNUNET_YES 34#define DEBUG_DV_MESSAGES GNUNET_NO
35#define DEBUG_DV GNUNET_NO 35#define DEBUG_DV GNUNET_NO
36#define DEBUG_DV_PEER_NUMBERS GNUNET_NO 36#define DEBUG_DV_PEER_NUMBERS GNUNET_NO
37#define DEBUG_MESSAGE_DROP GNUNET_NO 37#define DEBUG_MESSAGE_DROP GNUNET_NO
@@ -156,11 +156,6 @@ struct GNUNET_DV_SendMessage
156 struct GNUNET_PeerIdentity target; 156 struct GNUNET_PeerIdentity target;
157 157
158 /** 158 /**
159 * The size of the msgbuf
160 */
161 uint32_t msgbuf_size;
162
163 /**
164 * Message priority 159 * Message priority
165 */ 160 */
166 uint32_t priority; 161 uint32_t priority;
@@ -273,4 +268,11 @@ GNUNET_DV_connect (struct GNUNET_SCHEDULER_Handle *sched,
273 GNUNET_DV_MessageReceivedHandler receive_handler, 268 GNUNET_DV_MessageReceivedHandler receive_handler,
274 void *receive_handler_cls); 269 void *receive_handler_cls);
275 270
271/**
272 * Disconnect from the DV service
273 *
274 * @param handle the current handle to the service to disconnect
275 */
276void GNUNET_DV_disconnect(struct GNUNET_DV_Handle *handle);
277
276#endif 278#endif
diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c
index 9ab15ea62..8b92a703f 100644
--- a/src/dv/dv_api.c
+++ b/src/dv/dv_api.c
@@ -38,7 +38,9 @@
38#include "dv.h" 38#include "dv.h"
39#include "../transport/plugin_transport.h" 39#include "../transport/plugin_transport.h"
40 40
41 41/**
42 * Store ready to send messages
43 */
42struct PendingMessages 44struct PendingMessages
43{ 45{
44 /** 46 /**
@@ -58,8 +60,6 @@ struct PendingMessages
58 60
59}; 61};
60 62
61
62
63/** 63/**
64 * Handle for the service. 64 * Handle for the service.
65 */ 65 */
@@ -96,11 +96,6 @@ struct GNUNET_DV_Handle
96 struct PendingMessages *current; 96 struct PendingMessages *current;
97 97
98 /** 98 /**
99 * Kill off the connection and any pending messages.
100 */
101 int do_destroy;
102
103 /**
104 * Handler for messages we receive from the DV service 99 * Handler for messages we receive from the DV service
105 */ 100 */
106 GNUNET_DV_MessageReceivedHandler receive_handler; 101 GNUNET_DV_MessageReceivedHandler receive_handler;
@@ -171,6 +166,8 @@ hash_from_uid (uint32_t uid,
171/** 166/**
172 * Try to (re)connect to the dv service. 167 * Try to (re)connect to the dv service.
173 * 168 *
169 * @param ret handle to the (disconnected) dv service
170 *
174 * @return GNUNET_YES on success, GNUNET_NO on failure. 171 * @return GNUNET_YES on success, GNUNET_NO on failure.
175 */ 172 */
176static int 173static int
@@ -192,6 +189,9 @@ static void process_pending_message(struct GNUNET_DV_Handle *handle);
192 189
193/** 190/**
194 * Send complete, schedule next 191 * Send complete, schedule next
192 *
193 * @param handle handle to the dv service
194 * @param code return code for send (unused)
195 */ 195 */
196static void 196static void
197finish (struct GNUNET_DV_Handle *handle, int code) 197finish (struct GNUNET_DV_Handle *handle, int code)
@@ -204,7 +204,15 @@ finish (struct GNUNET_DV_Handle *handle, int code)
204 GNUNET_free (pos); 204 GNUNET_free (pos);
205} 205}
206 206
207 207/**
208 * Notification that we can send data
209 *
210 * @param cls handle to the dv service (struct GNUNET_DV_Handle)
211 * @param size how many bytes can we send
212 * @buf where to copy the message to send
213 *
214 * @return how many bytes we copied to buf
215 */
208static size_t 216static size_t
209transmit_pending (void *cls, size_t size, void *buf) 217transmit_pending (void *cls, size_t size, void *buf)
210{ 218{
@@ -249,6 +257,8 @@ transmit_pending (void *cls, size_t size, void *buf)
249 257
250/** 258/**
251 * Try to send messages from list of messages to send 259 * Try to send messages from list of messages to send
260 *
261 * @param handle handle to the distance vector service
252 */ 262 */
253static void process_pending_message(struct GNUNET_DV_Handle *handle) 263static void process_pending_message(struct GNUNET_DV_Handle *handle)
254{ 264{
@@ -265,11 +275,6 @@ static void process_pending_message(struct GNUNET_DV_Handle *handle)
265 handle->current = handle->pending_list; 275 handle->current = handle->pending_list;
266 if (NULL == handle->current) 276 if (NULL == handle->current)
267 { 277 {
268 if (handle->do_destroy)
269 {
270 handle->do_destroy = GNUNET_NO;
271 //GNUNET_DV_disconnect (handle); /* FIXME: replace with proper disconnect stuffs */
272 }
273 return; 278 return;
274 } 279 }
275 handle->pending_list = handle->pending_list->next; 280 handle->pending_list = handle->pending_list->next;
@@ -277,10 +282,10 @@ static void process_pending_message(struct GNUNET_DV_Handle *handle)
277 282
278 if (NULL == 283 if (NULL ==
279 (handle->th = GNUNET_CLIENT_notify_transmit_ready (handle->client, 284 (handle->th = GNUNET_CLIENT_notify_transmit_ready (handle->client,
280 ntohl(handle->current->msg->msgbuf_size), 285 ntohs(handle->current->msg->header.size),
281 handle->current->msg->timeout, 286 handle->current->msg->timeout,
282 GNUNET_YES, 287 GNUNET_YES,
283 &transmit_pending, handle))) 288 &transmit_pending, handle)))
284 { 289 {
285#if DEBUG_DV 290#if DEBUG_DV
286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -456,7 +461,6 @@ int GNUNET_DV_send (struct GNUNET_DV_Handle *dv_handle,
456 msg->header.size = htons(msize); 461 msg->header.size = htons(msize);
457 msg->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_SEND); 462 msg->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_SEND);
458 memcpy(&msg->target, target, sizeof(struct GNUNET_PeerIdentity)); 463 memcpy(&msg->target, target, sizeof(struct GNUNET_PeerIdentity));
459 msg->msgbuf_size = htonl(msgbuf_size);
460 msg->priority = htonl(priority); 464 msg->priority = htonl(priority);
461 msg->timeout = timeout; 465 msg->timeout = timeout;
462 msg->addrlen = htonl(addrlen); 466 msg->addrlen = htonl(addrlen);
@@ -476,9 +480,16 @@ int GNUNET_DV_send (struct GNUNET_DV_Handle *dv_handle,
476 return GNUNET_OK; 480 return GNUNET_OK;
477} 481}
478 482
479/* Forward declaration */ 483/**
480void GNUNET_DV_disconnect(struct GNUNET_DV_Handle *handle); 484 * Callback to transmit a start message to
481 485 * the DV service, once we can send
486 *
487 * @param cls struct StartContext
488 * @param size how much can we send
489 * @param buf where to copy the message
490 *
491 * @return number of bytes copied to buf
492 */
482static size_t 493static size_t
483transmit_start (void *cls, size_t size, void *buf) 494transmit_start (void *cls, size_t size, void *buf)
484{ 495{
@@ -531,7 +542,6 @@ GNUNET_DV_connect (struct GNUNET_SCHEDULER_Handle *sched,
531 handle->sched = sched; 542 handle->sched = sched;
532 handle->pending_list = NULL; 543 handle->pending_list = NULL;
533 handle->current = NULL; 544 handle->current = NULL;
534 handle->do_destroy = GNUNET_NO;
535 handle->th = NULL; 545 handle->th = NULL;
536 handle->client = GNUNET_CLIENT_connect(sched, "dv", cfg); 546 handle->client = GNUNET_CLIENT_connect(sched, "dv", cfg);
537 handle->receive_handler = receive_handler; 547 handle->receive_handler = receive_handler;
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c
index b89a0c1d9..20ce71952 100644
--- a/src/dv/gnunet-service-dv.c
+++ b/src/dv/gnunet-service-dv.c
@@ -503,7 +503,7 @@ static struct GNUNET_CORE_Handle *coreAPI;
503/** 503/**
504 * Stream tokenizer to handle messages coming in from core. 504 * Stream tokenizer to handle messages coming in from core.
505 */ 505 */
506struct GNUNET_SERVER_MessageStreamTokenizer *coreMST; 506static struct GNUNET_SERVER_MessageStreamTokenizer *coreMST;
507 507
508/** 508/**
509 * The identity of our peer. 509 * The identity of our peer.
@@ -1709,9 +1709,7 @@ void handle_dv_send_message (void *cls,
1709 1709
1710 address_len = ntohl(send_msg->addrlen); 1710 address_len = ntohl(send_msg->addrlen);
1711 GNUNET_assert(address_len == sizeof(struct GNUNET_PeerIdentity) * 2); 1711 GNUNET_assert(address_len == sizeof(struct GNUNET_PeerIdentity) * 2);
1712 message_size = ntohl(send_msg->msgbuf_size); 1712 message_size = ntohs(message->size) - sizeof(struct GNUNET_DV_SendMessage) - address_len;
1713
1714 GNUNET_assert(ntohs(message->size) == sizeof(struct GNUNET_DV_SendMessage) + address_len + message_size);
1715 destination = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity)); 1713 destination = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity));
1716 direct = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity)); 1714 direct = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity));
1717 message_buf = GNUNET_malloc(message_size); 1715 message_buf = GNUNET_malloc(message_size);
diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c
index f4811bbe9..30e5b6ac1 100644
--- a/src/dv/plugin_transport_dv.c
+++ b/src/dv/plugin_transport_dv.c
@@ -22,30 +22,10 @@
22 * @file dv/plugin_transport_dv.c 22 * @file dv/plugin_transport_dv.c
23 * @brief DV transport service, takes incoming DV requests and deals with 23 * @brief DV transport service, takes incoming DV requests and deals with
24 * the DV service 24 * the DV service
25 * @author Nathan Evans
25 * @author Christian Grothoff 26 * @author Christian Grothoff
26 */ 27 */
27 28
28/**
29 * TODO:
30 *
31 * As a start, the dv plugin needs to listen for information from the dv
32 * service. The plugin (?) will be notified by core (?) when a tcp/udp/whatever
33 * message comes in that should be for dv. The plugin will then hand off the message
34 * to the dv service which will decrypt/validate the message (?) and then send the
35 * result back to us (the transport) which will then send the message to the transport
36 * service (yikes).
37 *
38 * Or, core will notify the dv service directly which will validate,
39 * etc. and then just send a message to us.
40 *
41 * For starters, this plugin needs to have a client which will listen for messages from
42 * the dv service that need to be sent up to the gnunet-transport-service.
43 *
44 * Messages sent from the dv transport get passed to the dv service which deals
45 * with the actual sending (how much state does this transport need? should it know
46 * which peers it is currently connected to and their distances, or just assume that
47 * anything should be passed along to the dv service?).
48 */
49#include "platform.h" 29#include "platform.h"
50#include "gnunet_protocols.h" 30#include "gnunet_protocols.h"
51#include "gnunet_connection_lib.h" 31#include "gnunet_connection_lib.h"
@@ -434,6 +414,9 @@ libgnunet_plugin_transport_dv_done (void *cls)
434 struct GNUNET_TRANSPORT_PluginFunctions *api = cls; 414 struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
435 struct Plugin *plugin = api->cls; 415 struct Plugin *plugin = api->cls;
436 416
417 if (plugin->dv_handle != NULL)
418 GNUNET_DV_disconnect(plugin->dv_handle);
419
437 GNUNET_free (plugin); 420 GNUNET_free (plugin);
438 GNUNET_free (api); 421 GNUNET_free (api);
439 return NULL; 422 return NULL;
diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c
index 3cfabe237..faf279066 100644
--- a/src/dv/test_transport_api_dv.c
+++ b/src/dv/test_transport_api_dv.c
@@ -321,7 +321,15 @@ process_mtype (void *cls,
321 if ((total_messages_received == expected_messages) && (total_other_messages == 0)) 321 if ((total_messages_received == expected_messages) && (total_other_messages == 0))
322 { 322 {
323 GNUNET_SCHEDULER_cancel (sched, die_task); 323 GNUNET_SCHEDULER_cancel (sched, die_task);
324 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 420), &send_other_messages, NULL); 324 /*
325 if ((num_peers == 3) && (total_other_expected_messages == 2))
326 {
327 GNUNET_SCHEDULER_add_now (sched, &send_other_messages, NULL);
328 }
329 else
330 {
331 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20), &send_other_messages, NULL);
332 }*/
325 } 333 }
326 else if ((total_other_expected_messages > 0) && (total_other_messages == total_other_expected_messages)) 334 else if ((total_other_expected_messages > 0) && (total_other_messages == total_other_expected_messages))
327 { 335 {
@@ -827,6 +835,12 @@ static void all_connect_handler (void *cls,
827 fprintf(dotOutFile, "\tn%s -- n%s [color=brown];\n", d->shortname, second_shortname); 835 fprintf(dotOutFile, "\tn%s -- n%s [color=brown];\n", d->shortname, second_shortname);
828 } 836 }
829 GNUNET_free(second_shortname); 837 GNUNET_free(second_shortname);
838
839 if ((num_peers == 3) && (temp_total_other_messages == 2))
840 {
841 /*GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30), &send_other_messages, NULL);*/
842 GNUNET_SCHEDULER_add_now (sched, &send_other_messages, NULL);
843 }
830} 844}
831 845
832static void 846static void
@@ -1064,7 +1078,6 @@ main (int argc, char *argv[])
1064#endif 1078#endif
1065 NULL); 1079 NULL);
1066 ret = check (); 1080 ret = check ();
1067
1068 /** 1081 /**
1069 * Need to remove base directory, subdirectories taken care 1082 * Need to remove base directory, subdirectories taken care
1070 * of by the testing framework. 1083 * of by the testing framework.
diff --git a/src/dv/test_transport_dv_data.conf b/src/dv/test_transport_dv_data.conf
index 73d7f6876..e3e3bf250 100644
--- a/src/dv/test_transport_dv_data.conf
+++ b/src/dv/test_transport_dv_data.conf
@@ -10,14 +10,16 @@ DEBUG = NO
10PORT = 2565 10PORT = 2565
11PLUGINS = tcp dv 11PLUGINS = tcp dv
12BLACKLIST_FILE = $SERVICEHOME/blacklist 12BLACKLIST_FILE = $SERVICEHOME/blacklist
13#PREFIX = xterm -e xterm -T transport -e gdb --args 13#PREFIX = xterm -hold -T transport -e gdb --args
14#BINARY = /home/mrwiggles/documents/research/gnunet/gnunet-ng/src/transport/.libs/gnunet-service-transport 14#PREFIX = gdb --args
15#PREFIX = valgrind --tool=memcheck --log-file=logs%p 15BINARY = /home/mrwiggles/documents/research/gnunet/gnunet-ng/src/transport/.libs/gnunet-service-transport
16#BINARY = gnunet-service-transport
17PREFIX = valgrind --tool=memcheck --log-file=logs%p --track-origins=yes
16#DEBUG = YES 18#DEBUG = YES
17 19
18[arm] 20[arm]
19PORT = 2566 21PORT = 2566
20DEFAULTSERVICES = 22DEFAULTSERVICES = transport
21 23
22[statistics] 24[statistics]
23PORT = 2567 25PORT = 2567
@@ -43,7 +45,7 @@ PORT = 2570
43 45
44[dv] 46[dv]
45AUTOSTART = YES 47AUTOSTART = YES
46DEBUG = YES 48DEBUG = NO
47ACCEPT_FROM6 = ::1; 49ACCEPT_FROM6 = ::1;
48ACCEPT_FROM = 127.0.0.1; 50ACCEPT_FROM = 127.0.0.1;
49BINARY = gnunet-service-dv 51BINARY = gnunet-service-dv
@@ -58,7 +60,7 @@ PORT = 2571
58 60
59[testing] 61[testing]
60NUM_PEERS = 3 62NUM_PEERS = 3
61DEBUG = YES 63DEBUG = NO
62WEAKRANDOM = YES 64WEAKRANDOM = YES
63TOPOLOGY = CLIQUE 65TOPOLOGY = CLIQUE
64CONNECT_TOPOLOGY = LINE 66CONNECT_TOPOLOGY = LINE