aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-12-18 21:05:57 +0000
committerChristian Grothoff <christian@grothoff.org>2013-12-18 21:05:57 +0000
commit6be711e2b4a29d57e24c82f300338843f78ad604 (patch)
treef263a6b9e81e9f857a1ae3609c1ff800fe296f38
parentb6dc8a5a5871ad480cab1f84208ce2855a6f25fb (diff)
downloadgnunet-6be711e2b4a29d57e24c82f300338843f78ad604.tar.gz
gnunet-6be711e2b4a29d57e24c82f300338843f78ad604.zip
-misc fixes
-rw-r--r--src/dv/dv_api.c24
-rw-r--r--src/dv/gnunet-service-dv.c4
-rw-r--r--src/dv/plugin_transport_dv.c56
3 files changed, 69 insertions, 15 deletions
diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c
index 5932c7459..faf61df5e 100644
--- a/src/dv/dv_api.c
+++ b/src/dv/dv_api.c
@@ -426,6 +426,14 @@ handle_message_receipt (void *cls,
426 reconnect (sh); 426 reconnect (sh);
427 return; 427 return;
428 } 428 }
429 if (NULL ==
430 GNUNET_CONTAINER_multipeermap_get (sh->peers,
431 &rm->sender))
432 {
433 GNUNET_break (0);
434 reconnect (sh);
435 return;
436 }
429 sh->message_cb (sh->cls, 437 sh->message_cb (sh->cls,
430 &rm->sender, 438 &rm->sender,
431 ntohl (rm->distance), 439 ntohl (rm->distance),
@@ -443,7 +451,7 @@ handle_message_receipt (void *cls,
443 peer = GNUNET_CONTAINER_multipeermap_get (sh->peers, 451 peer = GNUNET_CONTAINER_multipeermap_get (sh->peers,
444 &ack->target); 452 &ack->target);
445 if (NULL == peer) 453 if (NULL == peer)
446 return; /* this happens, just ignore */ 454 break; /* this happens, just ignore */
447 for (th = peer->head; NULL != th; th = th->next) 455 for (th = peer->head; NULL != th; th = th->next)
448 { 456 {
449 if (th->uid != ntohl (ack->uid)) 457 if (th->uid != ntohl (ack->uid))
@@ -466,6 +474,9 @@ handle_message_receipt (void *cls,
466 reconnect (sh); 474 reconnect (sh);
467 break; 475 break;
468 } 476 }
477 LOG (GNUNET_ERROR_TYPE_DEBUG,
478 "Received message, continuing receive loop for %p\n",
479 sh->client);
469 GNUNET_CLIENT_receive (sh->client, 480 GNUNET_CLIENT_receive (sh->client,
470 &handle_message_receipt, sh, 481 &handle_message_receipt, sh,
471 GNUNET_TIME_UNIT_FOREVER_REL); 482 GNUNET_TIME_UNIT_FOREVER_REL);
@@ -499,6 +510,9 @@ transmit_start (void *cls,
499 start_message.size = htons (sizeof (struct GNUNET_MessageHeader)); 510 start_message.size = htons (sizeof (struct GNUNET_MessageHeader));
500 start_message.type = htons (GNUNET_MESSAGE_TYPE_DV_START); 511 start_message.type = htons (GNUNET_MESSAGE_TYPE_DV_START);
501 memcpy (buf, &start_message, sizeof (start_message)); 512 memcpy (buf, &start_message, sizeof (start_message));
513 LOG (GNUNET_ERROR_TYPE_DEBUG,
514 "Transmitting START request, starting receive loop for %p\n",
515 sh->client);
502 GNUNET_CLIENT_receive (sh->client, 516 GNUNET_CLIENT_receive (sh->client,
503 &handle_message_receipt, sh, 517 &handle_message_receipt, sh,
504 GNUNET_TIME_UNIT_FOREVER_REL); 518 GNUNET_TIME_UNIT_FOREVER_REL);
@@ -520,6 +534,9 @@ reconnect (struct GNUNET_DV_ServiceHandle *sh)
520 GNUNET_CLIENT_notify_transmit_ready_cancel (sh->th); 534 GNUNET_CLIENT_notify_transmit_ready_cancel (sh->th);
521 sh->th = NULL; 535 sh->th = NULL;
522 } 536 }
537 LOG (GNUNET_ERROR_TYPE_DEBUG,
538 "Disconnecting from DV service at %p\n",
539 sh->client);
523 if (NULL != sh->client) 540 if (NULL != sh->client)
524 { 541 {
525 GNUNET_CLIENT_disconnect (sh->client); 542 GNUNET_CLIENT_disconnect (sh->client);
@@ -643,10 +660,11 @@ GNUNET_DV_send (struct GNUNET_DV_ServiceHandle *sh,
643 return NULL; 660 return NULL;
644 } 661 }
645 LOG (GNUNET_ERROR_TYPE_DEBUG, 662 LOG (GNUNET_ERROR_TYPE_DEBUG,
646 "Asked to send %u bytes of type %u to %s\n", 663 "Asked to send %u bytes of type %u to %s via %p\n",
647 (unsigned int) ntohs (msg->size), 664 (unsigned int) ntohs (msg->size),
648 (unsigned int) ntohs (msg->type), 665 (unsigned int) ntohs (msg->type),
649 GNUNET_i2s (target)); 666 GNUNET_i2s (target),
667 sh->client);
650 peer = GNUNET_CONTAINER_multipeermap_get (sh->peers, 668 peer = GNUNET_CONTAINER_multipeermap_get (sh->peers,
651 target); 669 target);
652 if (NULL == peer) 670 if (NULL == peer)
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c
index 7cfbadbd5..43292e3aa 100644
--- a/src/dv/gnunet-service-dv.c
+++ b/src/dv/gnunet-service-dv.c
@@ -341,7 +341,7 @@ static struct GNUNET_CONTAINER_MultiPeerMap *direct_neighbors;
341/** 341/**
342 * Hashmap with all routes that we currently support; contains 342 * Hashmap with all routes that we currently support; contains
343 * routing information for all peers from distance 2 343 * routing information for all peers from distance 2
344 * up to distance DEFAULT_FISHEYE_DEPTH. 344 * up to distance #DEFAULT_FISHEYE_DEPTH.
345 */ 345 */
346static struct GNUNET_CONTAINER_MultiPeerMap *all_routes; 346static struct GNUNET_CONTAINER_MultiPeerMap *all_routes;
347 347
@@ -1974,7 +1974,7 @@ handle_dv_send_message (void *cls, struct GNUNET_SERVER_Client *client,
1974 GNUNET_i2s (&msg->target)); 1974 GNUNET_i2s (&msg->target));
1975 1975
1976 forward_payload (route->next_hop, 1976 forward_payload (route->next_hop,
1977 ntohl (route->target.distance), 1977 0 /* first hop, distance is zero */,
1978 htonl (msg->uid), 1978 htonl (msg->uid),
1979 &my_identity, 1979 &my_identity,
1980 &msg->target, 1980 &msg->target,
diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c
index 646603655..4baabe12e 100644
--- a/src/dv/plugin_transport_dv.c
+++ b/src/dv/plugin_transport_dv.c
@@ -70,7 +70,7 @@ struct PendingRequest
70 GNUNET_TRANSPORT_TransmitContinuation transmit_cont; 70 GNUNET_TRANSPORT_TransmitContinuation transmit_cont;
71 71
72 /** 72 /**
73 * Closure for transmit_cont. 73 * Closure for @e transmit_cont.
74 */ 74 */
75 void *transmit_cont_cls; 75 void *transmit_cont_cls;
76 76
@@ -84,6 +84,10 @@ struct PendingRequest
84 */ 84 */
85 struct Session *session; 85 struct Session *session;
86 86
87 /**
88 * Number of bytes to transmit.
89 */
90 size_t size;
87}; 91};
88 92
89 93
@@ -214,6 +218,12 @@ unbox_cb (void *cls,
214 ats.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); 218 ats.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
215 ats.value = htonl (session->distance); 219 ats.value = htonl (session->distance);
216 session->active = GNUNET_YES; 220 session->active = GNUNET_YES;
221 LOG (GNUNET_ERROR_TYPE_DEBUG,
222 "Delivering message of type %u with %u bytes from peer `%s'\n",
223 ntohs (message->type),
224 ntohs (message->size),
225 GNUNET_i2s (&session->sender));
226
217 plugin->env->receive (plugin->env->cls, 227 plugin->env->receive (plugin->env->cls,
218 &session->sender, 228 &session->sender,
219 message, 229 message,
@@ -245,8 +255,7 @@ handle_dv_message_received (void *cls,
245 struct Session *session; 255 struct Session *session;
246 256
247 LOG (GNUNET_ERROR_TYPE_DEBUG, 257 LOG (GNUNET_ERROR_TYPE_DEBUG,
248 "Received `%s' message for peer `%s': new distance %u\n", 258 "Received DV_MESSAGE_RECEIVED message for peer `%s': new distance %u\n",
249 "DV_MESSAGE_RECEIVED",
250 GNUNET_i2s (sender), distance); 259 GNUNET_i2s (sender), distance);
251 session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions, 260 session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions,
252 sender); 261 sender);
@@ -258,6 +267,8 @@ handle_dv_message_received (void *cls,
258 if (GNUNET_MESSAGE_TYPE_DV_BOX == ntohs (msg->type)) 267 if (GNUNET_MESSAGE_TYPE_DV_BOX == ntohs (msg->type))
259 { 268 {
260 /* need to unbox using MST */ 269 /* need to unbox using MST */
270 LOG (GNUNET_ERROR_TYPE_DEBUG,
271 "Unboxing DV message using MST\n");
261 GNUNET_SERVER_mst_receive (plugin->mst, 272 GNUNET_SERVER_mst_receive (plugin->mst,
262 session, 273 session,
263 (const char *) &msg[1], 274 (const char *) &msg[1],
@@ -269,6 +280,11 @@ handle_dv_message_received (void *cls,
269 ats.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); 280 ats.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
270 ats.value = htonl (distance); 281 ats.value = htonl (distance);
271 session->active = GNUNET_YES; 282 session->active = GNUNET_YES;
283 LOG (GNUNET_ERROR_TYPE_DEBUG,
284 "Delivering message of type %u with %u bytes from peer `%s'\n",
285 ntohs (msg->type),
286 ntohs (msg->size),
287 GNUNET_i2s (sender));
272 plugin->env->receive (plugin->env->cls, sender, 288 plugin->env->receive (plugin->env->cls, sender,
273 msg, 289 msg,
274 session, "", 0); 290 session, "", 0);
@@ -420,7 +436,8 @@ free_session (struct Session *session)
420 if (NULL != pr->transmit_cont) 436 if (NULL != pr->transmit_cont)
421 pr->transmit_cont (pr->transmit_cont_cls, 437 pr->transmit_cont (pr->transmit_cont_cls,
422 &session->sender, 438 &session->sender,
423 GNUNET_SYSERR, 0, 0); 439 GNUNET_SYSERR,
440 pr->size, 0);
424 GNUNET_free (pr); 441 GNUNET_free (pr);
425 } 442 }
426 GNUNET_free (session); 443 GNUNET_free (session);
@@ -473,7 +490,8 @@ send_finished (void *cls,
473 if (NULL != pr->transmit_cont) 490 if (NULL != pr->transmit_cont)
474 pr->transmit_cont (pr->transmit_cont_cls, 491 pr->transmit_cont (pr->transmit_cont_cls,
475 &session->sender, 492 &session->sender,
476 ok, 0, 0); 493 ok,
494 pr->size, 0);
477 GNUNET_free (pr); 495 GNUNET_free (pr);
478} 496}
479 497
@@ -516,6 +534,8 @@ dv_plugin_send (void *cls,
516 if (ntohs (msg->size) != msgbuf_size) 534 if (ntohs (msg->size) != msgbuf_size)
517 { 535 {
518 /* need to box */ 536 /* need to box */
537 LOG (GNUNET_ERROR_TYPE_DEBUG,
538 "Boxing DV message\n");
519 box = GNUNET_malloc (sizeof (struct GNUNET_MessageHeader) + msgbuf_size); 539 box = GNUNET_malloc (sizeof (struct GNUNET_MessageHeader) + msgbuf_size);
520 box->type = htons (GNUNET_MESSAGE_TYPE_DV_BOX); 540 box->type = htons (GNUNET_MESSAGE_TYPE_DV_BOX);
521 box->size = htons (sizeof (struct GNUNET_MessageHeader) + msgbuf_size); 541 box->size = htons (sizeof (struct GNUNET_MessageHeader) + msgbuf_size);
@@ -526,13 +546,14 @@ dv_plugin_send (void *cls,
526 pr->transmit_cont = cont; 546 pr->transmit_cont = cont;
527 pr->transmit_cont_cls = cont_cls; 547 pr->transmit_cont_cls = cont_cls;
528 pr->session = session; 548 pr->session = session;
549 pr->size = msgbuf_size;
529 GNUNET_CONTAINER_DLL_insert_tail (session->pr_head, 550 GNUNET_CONTAINER_DLL_insert_tail (session->pr_head,
530 session->pr_tail, 551 session->pr_tail,
531 pr); 552 pr);
532 553
533 pr->th = GNUNET_DV_send (plugin->dvh, 554 pr->th = GNUNET_DV_send (plugin->dvh,
534 &session->sender, 555 &session->sender,
535 msg , 556 msg,
536 &send_finished, 557 &send_finished,
537 pr); 558 pr);
538 GNUNET_free_non_null (box); 559 GNUNET_free_non_null (box);
@@ -570,7 +591,8 @@ dv_plugin_disconnect_peer (void *cls,
570 if (NULL != pr->transmit_cont) 591 if (NULL != pr->transmit_cont)
571 pr->transmit_cont (pr->transmit_cont_cls, 592 pr->transmit_cont (pr->transmit_cont_cls,
572 &session->sender, 593 &session->sender,
573 GNUNET_SYSERR, 0, 0); 594 GNUNET_SYSERR,
595 pr->size, 0);
574 GNUNET_free (pr); 596 GNUNET_free (pr);
575 } 597 }
576 session->active = GNUNET_NO; 598 session->active = GNUNET_NO;
@@ -602,7 +624,8 @@ dv_plugin_disconnect_session (void *cls,
602 if (NULL != pr->transmit_cont) 624 if (NULL != pr->transmit_cont)
603 pr->transmit_cont (pr->transmit_cont_cls, 625 pr->transmit_cont (pr->transmit_cont_cls,
604 &session->sender, 626 &session->sender,
605 GNUNET_SYSERR, 0, 0); 627 GNUNET_SYSERR,
628 pr->size, 0);
606 GNUNET_free (pr); 629 GNUNET_free (pr);
607 } 630 }
608 session->active = GNUNET_NO; 631 session->active = GNUNET_NO;
@@ -672,7 +695,7 @@ dv_plugin_address_to_string (void *cls,
672 * 695 *
673 * @param cls closure 696 * @param cls closure
674 * @param addr pointer to the address 697 * @param addr pointer to the address
675 * @param addrlen length of addr 698 * @param addrlen length of @a addr
676 * @return #GNUNET_OK if this is a plausible address for this peer 699 * @return #GNUNET_OK if this is a plausible address for this peer
677 * and transport, #GNUNET_SYSERR if not 700 * and transport, #GNUNET_SYSERR if not
678 * 701 *
@@ -743,14 +766,27 @@ dv_plugin_string_to_address (void *cls,
743 return GNUNET_SYSERR; 766 return GNUNET_SYSERR;
744} 767}
745 768
769
770/**
771 * Function that will be called whenever the transport service wants to
772 * notify the plugin that a session is still active and in use and
773 * therefore the session timeout for this session has to be updated
774 *
775 * @param cls closure (`struct Plugin *`)
776 * @param peer which peer was the session for
777 * @param session which session is being updated
778 */
746static void 779static void
747dv_plugin_update_session_timeout (void *cls, 780dv_plugin_update_session_timeout (void *cls,
748 const struct GNUNET_PeerIdentity *peer, 781 const struct GNUNET_PeerIdentity *peer,
749 struct Session *session) 782 struct Session *session)
750{ 783{
751 784 /* DV currently doesn't time out like "normal" plugins,
785 so it should be safe to do nothing, right?
786 (or should we add an internal timeout?) */
752} 787}
753 788
789
754/** 790/**
755 * Function to obtain the network type for a session 791 * Function to obtain the network type for a session
756 * FIXME: we should probably look at the network type 792 * FIXME: we should probably look at the network type