aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-05-07 13:36:39 +0000
committerBart Polot <bart@net.in.tum.de>2013-05-07 13:36:39 +0000
commit3029a328070bd5eb422261fb3559b01f415ae51c (patch)
tree2449b9e2ea7df62f7a7b40831d5bf0b52bfa6c83 /src
parentd9c88959e0bc6b817b609a816b4cb75f5e8c4c63 (diff)
downloadgnunet-3029a328070bd5eb422261fb3559b01f415ae51c.tar.gz
gnunet-3029a328070bd5eb422261fb3559b01f415ae51c.zip
- make mesh2 compile
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-service-mesh-new.c801
1 files changed, 184 insertions, 617 deletions
diff --git a/src/mesh/gnunet-service-mesh-new.c b/src/mesh/gnunet-service-mesh-new.c
index 79cfd5655..92215d44b 100644
--- a/src/mesh/gnunet-service-mesh-new.c
+++ b/src/mesh/gnunet-service-mesh-new.c
@@ -460,10 +460,9 @@ struct MeshTunnel
460 struct GNUNET_TIME_Absolute timestamp; 460 struct GNUNET_TIME_Absolute timestamp;
461 461
462 /** 462 /**
463 * Peers in the tunnel, indexed by PeerIdentity -> (MeshPeerInfo) 463 * Peer of the tunnel.
464 * containing peers added by id or by type, not intermediate peers.
465 */ 464 */
466 struct GNUNET_PEER_Id peer; 465 GNUNET_PEER_Id peer;
467 466
468 /** 467 /**
469 * Client owner of the tunnel, if any 468 * Client owner of the tunnel, if any
@@ -539,75 +538,6 @@ struct MeshTunnel
539 538
540 539
541/** 540/**
542 * Info about a child node in a tunnel, needed to perform flow control.
543 */
544struct MeshTunnelChildInfo
545{
546 /**
547 * ID of the child node.
548 */
549 GNUNET_PEER_Id id;
550
551 /**
552 * SKIP value.
553 */
554 uint32_t skip;
555
556 /**
557 * Last sent PID.
558 */
559 uint32_t fwd_pid;
560
561 /**
562 * Last received PID.
563 */
564 uint32_t bck_pid;
565
566 /**
567 * Maximum PID allowed (FWD ACK received).
568 */
569 uint32_t fwd_ack;
570
571 /**
572 * Last ACK sent to that child (BCK ACK).
573 */
574 uint32_t bck_ack;
575
576 /**
577 * Circular buffer pointing to MeshPeerQueue elements for all
578 * payload traffic going to this child.
579 * Size determined by the tunnel queue size (@c t->fwd_queue_max).
580 */
581 struct MeshPeerQueue **send_buffer;
582
583 /**
584 * Index of the oldest element in the send_buffer.
585 */
586 unsigned int send_buffer_start;
587
588 /**
589 * How many elements are already in the buffer.
590 */
591 unsigned int send_buffer_n;
592
593 /**
594 * Tunnel this info is about
595 */
596 struct MeshTunnel *t;
597
598 /**
599 * Task to poll peer in case of a stall.
600 */
601 GNUNET_SCHEDULER_TaskIdentifier fc_poll;
602
603 /**
604 * Time to use for next polling call.
605 */
606 struct GNUNET_TIME_Relative fc_poll_time;
607};
608
609
610/**
611 * Info about a leaf client of a tunnel, needed to perform flow control. 541 * Info about a leaf client of a tunnel, needed to perform flow control.
612 */ 542 */
613struct MeshTunnelClientInfo 543struct MeshTunnelClientInfo
@@ -634,35 +564,6 @@ struct MeshTunnelClientInfo
634}; 564};
635 565
636 566
637
638/**
639 * Info collected during iteration of child nodes in order to get the ACK value
640 * for a tunnel.
641 */
642struct MeshTunnelChildIteratorContext
643{
644 /**
645 * Tunnel whose info is being collected.
646 */
647 struct MeshTunnel *t;
648
649 /**
650 * Is this context initialized? Is the value in max_child_ack valid?
651 */
652 int init;
653
654 /**
655 * Maximum child ACK so far.
656 */
657 uint32_t max_child_ack;
658
659 /**
660 * Number of children nodes
661 */
662 unsigned int nchildren;
663};
664
665
666/** 567/**
667 * Info needed to work with tunnel paths and peers 568 * Info needed to work with tunnel paths and peers
668 */ 569 */
@@ -1042,30 +943,6 @@ static void
1042path_add_to_peers (struct MeshPeerPath *p, int confirmed); 943path_add_to_peers (struct MeshPeerPath *p, int confirmed);
1043 944
1044 945
1045/**
1046 * Add a peer to a tunnel, accomodating paths accordingly and initializing all
1047 * needed rescources.
1048 * If peer already exists, reevaluate shortest path and change if different.
1049 *
1050 * @param t Tunnel we want to add a new peer to
1051 * @param peer PeerInfo of the peer being added
1052 *
1053 */
1054static void
1055tunnel_add_peer (struct MeshTunnel *t, struct MeshPeerInfo *peer);
1056
1057
1058/**
1059 * Removes an explicit path from a tunnel, freeing all intermediate nodes
1060 * that are no longer needed, as well as nodes of no longer reachable peers.
1061 * The tunnel itself is also destoyed if results in a remote empty tunnel.
1062 *
1063 * @param t Tunnel from which to remove the path.
1064 * @param peer Short id of the peer which should be removed.
1065 */
1066static void
1067tunnel_delete_peer (struct MeshTunnel *t, GNUNET_PEER_Id peer);
1068
1069 946
1070/** 947/**
1071 * Search for a tunnel by global ID using full PeerIdentities. 948 * Search for a tunnel by global ID using full PeerIdentities.
@@ -1409,32 +1286,6 @@ client_delete_tunnel (struct MeshClient *c, struct MeshTunnel *t)
1409 1286
1410 1287
1411/** 1288/**
1412 * Notify the owner of a tunnel that a peer has disconnected.
1413 *
1414 * @param c Client (owner of tunnel).
1415 * @param t Tunnel this message is about.
1416 * @param peer_id Short ID of the disconnected peer.
1417 */
1418void
1419client_notify_peer_disconnected (struct MeshClient *c,
1420 struct MeshTunnel *t,
1421 GNUNET_PEER_Id peer_id)
1422{
1423 struct GNUNET_MESH_PeerControl msg;
1424
1425 if (NULL == t->owner || NULL == nc)
1426 return;
1427
1428 msg.header.size = htons (sizeof (msg));
1429 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_DEL);
1430 msg.tunnel_id = htonl (t->local_tid);
1431 GNUNET_PEER_resolve (peer_id, &msg.peer);
1432 GNUNET_SERVER_notification_context_unicast (nc, t->owner->handle,
1433 &msg.header, GNUNET_NO);
1434}
1435
1436
1437/**
1438 * Send the message to all clients that have subscribed to its type 1289 * Send the message to all clients that have subscribed to its type
1439 * 1290 *
1440 * @param msg Pointer to the message itself 1291 * @param msg Pointer to the message itself
@@ -1463,17 +1314,12 @@ send_subscribed_clients (const struct GNUNET_MessageHeader *msg,
1463 switch (htons (msg->type)) 1314 switch (htons (msg->type))
1464 { 1315 {
1465 struct GNUNET_MESH_Unicast *uc; 1316 struct GNUNET_MESH_Unicast *uc;
1466 struct GNUNET_MESH_Multicast *mc;
1467 struct GNUNET_MESH_ToOrigin *to; 1317 struct GNUNET_MESH_ToOrigin *to;
1468 1318
1469 case GNUNET_MESSAGE_TYPE_MESH_UNICAST: 1319 case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
1470 uc = (struct GNUNET_MESH_Unicast *) cbuf; 1320 uc = (struct GNUNET_MESH_Unicast *) cbuf;
1471 tid = &uc->tid; 1321 tid = &uc->tid;
1472 break; 1322 break;
1473 case GNUNET_MESSAGE_TYPE_MESH_MULTICAST:
1474 mc = (struct GNUNET_MESH_Multicast *) cbuf;
1475 tid = &mc->tid;
1476 break;
1477 case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: 1323 case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
1478 to = (struct GNUNET_MESH_ToOrigin *) cbuf; 1324 to = (struct GNUNET_MESH_ToOrigin *) cbuf;
1479 tid = &to->tid; 1325 tid = &to->tid;
@@ -1508,8 +1354,6 @@ send_subscribed_clients (const struct GNUNET_MessageHeader *msg,
1508 GNUNET_PEER_resolve (t->id.oid, &tmsg.peer); 1354 GNUNET_PEER_resolve (t->id.oid, &tmsg.peer);
1509 tmsg.tunnel_id = htonl (t->local_tid_dest); 1355 tmsg.tunnel_id = htonl (t->local_tid_dest);
1510 tmsg.opt = 0; 1356 tmsg.opt = 0;
1511 if (GNUNET_YES == t->speed_min)
1512 tmsg.opt |= MESH_TUNNEL_OPT_SPEED_MIN;
1513 if (GNUNET_YES == t->nobuffer) 1357 if (GNUNET_YES == t->nobuffer)
1514 tmsg.opt |= MESH_TUNNEL_OPT_NOBUFFER; 1358 tmsg.opt |= MESH_TUNNEL_OPT_NOBUFFER;
1515 GNUNET_SERVER_notification_context_unicast (nc, c->handle, 1359 GNUNET_SERVER_notification_context_unicast (nc, c->handle,
@@ -1540,30 +1384,6 @@ send_subscribed_clients (const struct GNUNET_MessageHeader *msg,
1540 1384
1541 1385
1542/** 1386/**
1543 * Notify the client that owns the tunnel that a peer has connected to it
1544 * (the requested path to it has been confirmed).
1545 *
1546 * @param t Tunnel whose owner to notify
1547 * @param id Short id of the peer that has connected
1548 */
1549static void
1550send_client_peer_connected (const struct MeshTunnel *t, const GNUNET_PEER_Id id)
1551{
1552 struct GNUNET_MESH_PeerControl pc;
1553
1554 if (NULL == t->owner || GNUNET_YES == t->destroy)
1555 return;
1556
1557 pc.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD);
1558 pc.header.size = htons (sizeof (struct GNUNET_MESH_PeerControl));
1559 pc.tunnel_id = htonl (t->local_tid);
1560 GNUNET_PEER_resolve (id, &pc.peer);
1561 GNUNET_SERVER_notification_context_unicast (nc, t->owner->handle, &pc.header,
1562 GNUNET_NO);
1563}
1564
1565
1566/**
1567 * Notify all clients (not depending on registration status) that the incoming 1387 * Notify all clients (not depending on registration status) that the incoming
1568 * tunnel is no longer valid. 1388 * tunnel is no longer valid.
1569 * 1389 *
@@ -1609,17 +1429,6 @@ send_client_tunnel_disconnect (struct MeshTunnel *t, struct MeshClient *c)
1609 &msg.header, GNUNET_NO); 1429 &msg.header, GNUNET_NO);
1610 } 1430 }
1611 // FIXME when to disconnect an incoming tunnel? 1431 // FIXME when to disconnect an incoming tunnel?
1612 else if (1 == t->nclients && NULL != t->owner)
1613 {
1614 struct GNUNET_MESH_PeerControl msg;
1615
1616 msg.header.size = htons (sizeof (msg));
1617 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_DEL);
1618 msg.tunnel_id = htonl (t->local_tid);
1619 msg.peer = my_full_id;
1620 GNUNET_SERVER_notification_context_unicast (nc, t->owner->handle,
1621 &msg.header, GNUNET_NO);
1622 }
1623} 1432}
1624 1433
1625 1434
@@ -2013,7 +1822,6 @@ peer_info_connect (struct MeshPeerInfo *peer, struct MeshTunnel *t)
2013 struct GNUNET_HashCode hash; 1822 struct GNUNET_HashCode hash;
2014 1823
2015 path_destroy (p); 1824 path_destroy (p);
2016 send_client_peer_connected (t, myid);
2017 t->local_tid_dest = next_local_tid++; 1825 t->local_tid_dest = next_local_tid++;
2018 GNUNET_CRYPTO_hash (&t->local_tid_dest, sizeof (MESH_TunnelNumber), 1826 GNUNET_CRYPTO_hash (&t->local_tid_dest, sizeof (MESH_TunnelNumber),
2019 &hash); 1827 &hash);
@@ -2322,7 +2130,7 @@ peer_info_add_path_to_origin (struct MeshPeerInfo *peer_info,
2322} 2130}
2323 2131
2324 2132
2325/** 2133/** FIXME
2326 * Function called if the connection to the peer has been stalled for a while, 2134 * Function called if the connection to the peer has been stalled for a while,
2327 * possibly due to a missed ACK. Poll the peer about its ACK status. 2135 * possibly due to a missed ACK. Poll the peer about its ACK status.
2328 * 2136 *
@@ -2332,31 +2140,30 @@ peer_info_add_path_to_origin (struct MeshPeerInfo *peer_info,
2332static void 2140static void
2333tunnel_poll (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 2141tunnel_poll (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2334{ 2142{
2335 struct MeshTunnelChildInfo *cinfo = cls; 2143// struct GNUNET_MESH_Poll msg;
2336 struct GNUNET_MESH_Poll msg; 2144// struct GNUNET_PeerIdentity id;
2337 struct GNUNET_PeerIdentity id; 2145// struct MeshTunnel *t;
2338 struct MeshTunnel *t;
2339 2146
2340 cinfo->fc_poll = GNUNET_SCHEDULER_NO_TASK; 2147// cinfo->fc_poll = GNUNET_SCHEDULER_NO_TASK;
2341 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 2148 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
2342 { 2149 {
2343 return; 2150 return;
2344 } 2151 }
2345 2152
2346 t = cinfo->t; 2153// t = cinfo->t;
2347 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_POLL); 2154// msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_POLL);
2348 msg.header.size = htons (sizeof (msg)); 2155// msg.header.size = htons (sizeof (msg));
2349 msg.tid = htonl (t->id.tid); 2156// msg.tid = htonl (t->id.tid);
2350 GNUNET_PEER_resolve (t->id.oid, &msg.oid); 2157// GNUNET_PEER_resolve (t->id.oid, &msg.oid);
2351 msg.last_ack = htonl (cinfo->fwd_ack); 2158// msg.last_ack = htonl (cinfo->fwd_ack);
2352 2159//
2353 GNUNET_PEER_resolve (cinfo->id, &id); 2160// GNUNET_PEER_resolve (cinfo->id, &id);
2354 send_prebuilt_message (&msg.header, &id, cinfo->t); 2161// send_prebuilt_message (&msg.header, &id, cinfo->t);
2355 cinfo->fc_poll_time = GNUNET_TIME_relative_min ( 2162// cinfo->fc_poll_time = GNUNET_TIME_relative_min (
2356 MESH_MAX_POLL_TIME, 2163// MESH_MAX_POLL_TIME,
2357 GNUNET_TIME_relative_multiply (cinfo->fc_poll_time, 2)); 2164// GNUNET_TIME_relative_multiply (cinfo->fc_poll_time, 2));
2358 cinfo->fc_poll = GNUNET_SCHEDULER_add_delayed (cinfo->fc_poll_time, 2165// cinfo->fc_poll = GNUNET_SCHEDULER_add_delayed (cinfo->fc_poll_time,
2359 &tunnel_poll, cinfo); 2166// &tunnel_poll, cinfo);
2360} 2167}
2361 2168
2362 2169
@@ -2630,76 +2437,6 @@ tunnel_delete_client (struct MeshTunnel *t, const struct MeshClient *c)
2630 2437
2631 2438
2632/** 2439/**
2633 * @brief Iterator to destroy MeshTunnelChildInfo of tunnel children.
2634 *
2635 * Destroys queue elements of all waiting transmissions and frees all memory
2636 * used by the struct and its elements.
2637 *
2638 * @param cls Closure (tunnel info).
2639 * @param key Hash of GNUNET_PEER_Id (unused).
2640 * @param value MeshTunnelChildInfo of the child.
2641 *
2642 * @return always GNUNET_YES, to keep iterating
2643 */
2644static int
2645tunnel_destroy_child (void *cls,
2646 const struct GNUNET_HashCode * key,
2647 void *value)
2648{
2649 struct MeshTunnelChildInfo *cinfo = value;
2650 struct MeshTunnel *t = cls;
2651 struct MeshPeerQueue *q;
2652 unsigned int c;
2653 unsigned int i;
2654
2655 for (c = 0; c < cinfo->send_buffer_n; c++)
2656 {
2657 i = (cinfo->send_buffer_start + c) % t->fwd_queue_max;
2658 q = cinfo->send_buffer[i];
2659 cinfo->send_buffer[i] = NULL;
2660 if (NULL != q)
2661 queue_destroy (q, GNUNET_YES);
2662 else
2663 GNUNET_break (0);
2664 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u %u\n", c, cinfo->send_buffer_n);
2665 }
2666 GNUNET_free_non_null (cinfo->send_buffer);
2667 if (GNUNET_SCHEDULER_NO_TASK != cinfo->fc_poll)
2668 {
2669 GNUNET_SCHEDULER_cancel (cinfo->fc_poll);
2670 cinfo->fc_poll = GNUNET_SCHEDULER_NO_TASK;
2671 }
2672 GNUNET_free (cinfo);
2673 return GNUNET_YES;
2674}
2675
2676
2677/**
2678 * Callback used to notify a client owner of a tunnel that a peer has
2679 * disconnected, most likely because of a path change.
2680 *
2681 * @param cls Closure (tunnel this notification is about).
2682 * @param peer_id Short ID of disconnected peer.
2683 */
2684void
2685tunnel_notify_client_peer_disconnected (void *cls, GNUNET_PEER_Id peer_id)
2686{
2687 struct MeshTunnel *t = cls;
2688 struct MeshPeerInfo *peer;
2689 struct MeshPathInfo *path_info;
2690
2691 client_notify_peer_disconnected (t->owner, t, peer_id);
2692
2693 peer = peer_info_get_short (peer_id);
2694 path_info = GNUNET_malloc (sizeof (struct MeshPathInfo));
2695 path_info->peer = peer;
2696 path_info->t = t;
2697 peer->connect_task = GNUNET_SCHEDULER_add_now (&peer_info_connect_task,
2698 path_info);
2699}
2700
2701
2702/**
2703 * Add a peer to a tunnel, accomodating paths accordingly and initializing all 2440 * Add a peer to a tunnel, accomodating paths accordingly and initializing all
2704 * needed rescources. 2441 * needed rescources.
2705 * If peer already exists, reevaluate shortest path and change if different. 2442 * If peer already exists, reevaluate shortest path and change if different.
@@ -2737,7 +2474,7 @@ tunnel_add_peer (struct MeshTunnel *t, struct MeshPeerInfo *peer)
2737 } 2474 }
2738 p = p->next; 2475 p = p->next;
2739 } 2476 }
2740 tree_add_path (t->tree, best_p, &tunnel_notify_client_peer_disconnected, t); 2477 tree_add_path (t->tree, best_p, NULL, NULL); // FIXME
2741 if (GNUNET_SCHEDULER_NO_TASK == t->path_refresh_task) 2478 if (GNUNET_SCHEDULER_NO_TASK == t->path_refresh_task)
2742 t->path_refresh_task = 2479 t->path_refresh_task =
2743 GNUNET_SCHEDULER_add_delayed (refresh_path_time, &path_refresh, t); 2480 GNUNET_SCHEDULER_add_delayed (refresh_path_time, &path_refresh, t);
@@ -2815,35 +2552,27 @@ static GNUNET_PEER_Id
2815tunnel_notify_connection_broken (struct MeshTunnel *t, GNUNET_PEER_Id p1, 2552tunnel_notify_connection_broken (struct MeshTunnel *t, GNUNET_PEER_Id p1,
2816 GNUNET_PEER_Id p2) 2553 GNUNET_PEER_Id p2)
2817{ 2554{
2818 GNUNET_PEER_Id pid; 2555// if (myid != p1 && myid != p2) FIXME
2819 2556// {
2820 pid = 2557// return;
2821 tree_notify_connection_broken (t->tree, p1, p2, 2558// }
2822 &tunnel_notify_client_peer_disconnected, 2559//
2823 t); 2560// if (tree_get_predecessor (t->tree) != 0)
2824 if (myid != p1 && myid != p2) 2561// {
2825 { 2562// /* We are the peer still connected, notify owner of the disconnection. */
2826 return pid; 2563// struct GNUNET_MESH_PathBroken msg;
2827 } 2564// struct GNUNET_PeerIdentity neighbor;
2828 if (pid != myid) 2565//
2829 { 2566// msg.header.size = htons (sizeof (msg));
2830 if (tree_get_predecessor (t->tree) != 0) 2567// msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN);
2831 { 2568// GNUNET_PEER_resolve (t->id.oid, &msg.oid);
2832 /* We are the peer still connected, notify owner of the disconnection. */ 2569// msg.tid = htonl (t->id.tid);
2833 struct GNUNET_MESH_PathBroken msg; 2570// msg.peer1 = my_full_id;
2834 struct GNUNET_PeerIdentity neighbor; 2571// GNUNET_PEER_resolve (pid, &msg.peer2);
2835 2572// GNUNET_PEER_resolve (tree_get_predecessor (t->tree), &neighbor);
2836 msg.header.size = htons (sizeof (msg)); 2573// send_prebuilt_message (&msg.header, &neighbor, t);
2837 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN); 2574// }
2838 GNUNET_PEER_resolve (t->id.oid, &msg.oid); 2575 return 0;
2839 msg.tid = htonl (t->id.tid);
2840 msg.peer1 = my_full_id;
2841 GNUNET_PEER_resolve (pid, &msg.peer2);
2842 GNUNET_PEER_resolve (tree_get_predecessor (t->tree), &neighbor);
2843 send_prebuilt_message (&msg.header, &neighbor, t);
2844 }
2845 }
2846 return pid;
2847} 2576}
2848 2577
2849 2578
@@ -2873,72 +2602,6 @@ tunnel_get_client_fc (struct MeshTunnel *t,
2873 2602
2874 2603
2875/** 2604/**
2876 * Iterator to get the appropiate ACK value from all children nodes.
2877 *
2878 * @param cls Closue (tunnel).
2879 * @param id Id of the child node.
2880 */
2881static void
2882tunnel_get_child_fwd_ack (void *cls,
2883 GNUNET_PEER_Id id)
2884{
2885 struct GNUNET_PeerIdentity peer_id;
2886 struct MeshTunnelChildInfo *cinfo;
2887 struct MeshTunnelChildIteratorContext *ctx = cls;
2888 struct MeshTunnel *t = ctx->t;
2889 uint32_t ack;
2890
2891 GNUNET_PEER_resolve (id, &peer_id);
2892 cinfo = tunnel_get_neighbor_fc (t, &peer_id);
2893 ack = cinfo->fwd_ack;
2894
2895 ctx->nchildren++;
2896 if (GNUNET_NO == ctx->init)
2897 {
2898 ctx->max_child_ack = ack;
2899 ctx->init = GNUNET_YES;
2900 }
2901
2902 /* FIXME check */
2903 ctx->max_child_ack = ctx->max_child_ack > ack ? ctx->max_child_ack : ack;
2904
2905}
2906
2907
2908/**
2909 * Get the maximum PID allowed to transmit to any
2910 * tunnel child of the local peer, depending on the tunnel
2911 * buffering/speed settings.
2912 *
2913 * @param t Tunnel.
2914 *
2915 * @return Maximum PID allowed (uint32 MAX), -1LL if node has no children.
2916 */
2917static int64_t
2918tunnel_get_children_fwd_ack (struct MeshTunnel *t)
2919{
2920 struct MeshTunnelChildIteratorContext ctx;
2921 ctx.t = t;
2922 ctx.max_child_ack = 0;
2923 ctx.nchildren = 0;
2924 ctx.init = GNUNET_NO;
2925 tree_iterate_children (t->tree, tunnel_get_child_fwd_ack, &ctx);
2926
2927 if (0 == ctx.nchildren)
2928 {
2929 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2930 " tunnel has no children, no FWD ACK\n");
2931 return -1LL;
2932 }
2933
2934 if (GNUNET_YES == t->nobuffer && GMC_is_pid_bigger(ctx.max_child_ack, t->fwd_pid))
2935 ctx.max_child_ack = t->fwd_pid + 1; // Might overflow, it's ok.
2936
2937 return (int64_t) ctx.max_child_ack;
2938}
2939
2940
2941/**
2942 * Set the FWD ACK value of a client in a particular tunnel. 2605 * Set the FWD ACK value of a client in a particular tunnel.
2943 * 2606 *
2944 * @param t Tunnel affected. 2607 * @param t Tunnel affected.
@@ -3001,7 +2664,7 @@ tunnel_get_clients_fwd_ack (struct MeshTunnel *t)
3001} 2664}
3002 2665
3003 2666
3004/** 2667/** FIXME
3005 * Get the current fwd ack value for a tunnel, taking in account the tunnel 2668 * Get the current fwd ack value for a tunnel, taking in account the tunnel
3006 * mode and the status of all children nodes. 2669 * mode and the status of all children nodes.
3007 * 2670 *
@@ -3015,50 +2678,29 @@ tunnel_get_fwd_ack (struct MeshTunnel *t)
3015 uint32_t ack; 2678 uint32_t ack;
3016 uint32_t count; 2679 uint32_t count;
3017 uint32_t buffer_free; 2680 uint32_t buffer_free;
3018 int64_t child_ack;
3019 int64_t client_ack; 2681 int64_t client_ack;
3020 2682
3021 count = t->fwd_pid; 2683 count = t->fwd_pid;
3022 buffer_free = t->fwd_queue_max - t->fwd_queue_n; 2684 buffer_free = t->fwd_queue_max - t->fwd_queue_n;
3023 child_ack = tunnel_get_children_fwd_ack (t);
3024 client_ack = tunnel_get_clients_fwd_ack (t); 2685 client_ack = tunnel_get_clients_fwd_ack (t);
3025 if (GNUNET_YES == t->nobuffer) 2686 if (GNUNET_YES == t->nobuffer)
3026 { 2687 {
3027 ack = count; 2688 ack = count;
3028 if (-1LL == child_ack)
3029 child_ack = client_ack;
3030 if (-1LL == child_ack)
3031 {
3032 GNUNET_break (0);
3033 client_ack = child_ack = ack;
3034 }
3035 } 2689 }
3036 else 2690 else
3037 { 2691 {
3038 ack = count + buffer_free; // Overflow? OK! 2692 ack = count + buffer_free; // Overflow? OK!
3039 } 2693 }
3040 if (-1LL == child_ack)
3041 {
3042 // Node has no children, child_ack AND core buffer are irrelevant.
3043 if (-1LL == client_ack) // No children AND no clients? Not good!
3044 {
3045 GNUNET_STATISTICS_update (stats, "# mesh acks with no target",
3046 1, GNUNET_NO);
3047
3048 }
3049 return (uint32_t) client_ack;
3050 }
3051 if (-1LL == client_ack) 2694 if (-1LL == client_ack)
3052 { 2695 {
3053 client_ack = ack; 2696 client_ack = ack;
3054 } 2697 }
3055 /* FIXME check */ 2698 /* FIXME check */
3056 ack = GMC_max_pid ((uint32_t) child_ack, ack);
3057 ack = GMC_max_pid ((uint32_t) client_ack, ack); 2699 ack = GMC_max_pid ((uint32_t) client_ack, ack);
3058 2700
3059 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2701 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3060 "c %u, bf %u, ch %lld, cl %lld, ACK: %u\n", 2702 "c %u, bf %u, cl %lld, ACK: %u\n",
3061 count, buffer_free, child_ack, client_ack, ack); 2703 count, buffer_free, client_ack, ack);
3062 return ack; 2704 return ack;
3063} 2705}
3064 2706
@@ -3227,25 +2869,23 @@ tunnel_send_child_bck_ack (void *cls,
3227 GNUNET_PEER_Id id) 2869 GNUNET_PEER_Id id)
3228{ 2870{
3229 struct MeshTunnel *t = cls; 2871 struct MeshTunnel *t = cls;
3230 struct MeshTunnelChildInfo *cinfo;
3231 struct GNUNET_PeerIdentity peer; 2872 struct GNUNET_PeerIdentity peer;
3232 uint32_t ack; 2873 uint32_t ack = 0; // FIXME
3233 2874
3234 GNUNET_PEER_resolve (id, &peer); 2875 GNUNET_PEER_resolve (id, &peer);
3235 cinfo = tunnel_get_neighbor_fc (t, &peer); 2876// ack = cinfo->bck_pid + t->bck_queue_max - t->bck_queue_n;
3236 ack = cinfo->bck_pid + t->bck_queue_max - t->bck_queue_n; 2877//
3237 2878// if (cinfo->bck_ack == ack && GNUNET_NO == t->force_ack)
3238 if (cinfo->bck_ack == ack && GNUNET_NO == t->force_ack) 2879// {
3239 { 2880// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3240 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2881// " Not sending ACK, not needed\n");
3241 " Not sending ACK, not needed\n"); 2882// return;
3242 return; 2883// }
3243 } 2884// cinfo->bck_ack = ack;
3244 cinfo->bck_ack = ack; 2885//
3245 2886// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3246 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2887// " Sending BCK ACK %u (last sent: %u)\n",
3247 " Sending BCK ACK %u (last sent: %u)\n", 2888// ack, cinfo->bck_ack);
3248 ack, cinfo->bck_ack);
3249 send_ack (t, &peer, ack); 2889 send_ack (t, &peer, ack);
3250} 2890}
3251 2891
@@ -3589,12 +3229,6 @@ tunnel_destroy (struct MeshTunnel *t)
3589 GNUNET_free_non_null (t->ignore); 3229 GNUNET_free_non_null (t->ignore);
3590 GNUNET_free_non_null (t->clients_fc); 3230 GNUNET_free_non_null (t->clients_fc);
3591 3231
3592 GNUNET_CONTAINER_multihashmap_iterate (t->children_fc,
3593 &tunnel_destroy_child,
3594 t);
3595 GNUNET_CONTAINER_multihashmap_destroy (t->children_fc);
3596 t->children_fc = NULL;
3597
3598 tree_iterate_children (t->tree, &tunnel_cancel_queues, t); 3232 tree_iterate_children (t->tree, &tunnel_cancel_queues, t);
3599 tree_destroy (t->tree); 3233 tree_destroy (t->tree);
3600 3234
@@ -3720,7 +3354,6 @@ tunnel_new (GNUNET_PEER_Id owner,
3720 t->bck_ack = INITIAL_WINDOW_SIZE - 1; 3354 t->bck_ack = INITIAL_WINDOW_SIZE - 1;
3721 t->last_fwd_ack = INITIAL_WINDOW_SIZE - 1; 3355 t->last_fwd_ack = INITIAL_WINDOW_SIZE - 1;
3722 t->local_tid = local; 3356 t->local_tid = local;
3723 t->children_fc = GNUNET_CONTAINER_multihashmap_create (8, GNUNET_NO);
3724 n_tunnels++; 3357 n_tunnels++;
3725 GNUNET_STATISTICS_update (stats, "# tunnels", 1, GNUNET_NO); 3358 GNUNET_STATISTICS_update (stats, "# tunnels", 1, GNUNET_NO);
3726 3359
@@ -3756,41 +3389,6 @@ tunnel_new (GNUNET_PEER_Id owner,
3756 return t; 3389 return t;
3757} 3390}
3758 3391
3759/**
3760 * Callback when removing children from a tunnel tree. Notify owner.
3761 *
3762 * @param cls Closure (tunnel).
3763 * @param peer_id Short ID of the peer deleted.
3764 */
3765void
3766tunnel_child_removed (void *cls, GNUNET_PEER_Id peer_id)
3767{
3768 struct MeshTunnel *t = cls;
3769
3770 client_notify_peer_disconnected (t->owner, t, peer_id);
3771}
3772
3773/**
3774 * Removes an explicit path from a tunnel, freeing all intermediate nodes
3775 * that are no longer needed, as well as nodes of no longer reachable peers.
3776 * The tunnel itself is also destoyed if results in a remote empty tunnel.
3777 *
3778 * @param t Tunnel from which to remove the path.
3779 * @param peer Short id of the peer which should be removed.
3780 */
3781static void
3782tunnel_delete_peer (struct MeshTunnel *t, GNUNET_PEER_Id peer)
3783{
3784 int r;
3785
3786 r = tree_del_peer (t->tree, peer, &tunnel_child_removed, t);
3787 if (GNUNET_NO == r)
3788 {
3789 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3790 "Tunnel %u [%u] has no more nodes\n",
3791 t->id.oid, t->id.tid);
3792 }
3793}
3794 3392
3795 3393
3796/** 3394/**
@@ -4022,10 +3620,7 @@ queue_destroy (struct MeshPeerQueue *queue, int clear_cls)
4022{ 3620{
4023 struct MeshTransmissionDescriptor *dd; 3621 struct MeshTransmissionDescriptor *dd;
4024 struct MeshPathInfo *path_info; 3622 struct MeshPathInfo *path_info;
4025 struct MeshTunnelChildInfo *cinfo; 3623// unsigned int max;
4026 struct GNUNET_PeerIdentity id;
4027 unsigned int i;
4028 unsigned int max;
4029 3624
4030 if (GNUNET_YES == clear_cls) 3625 if (GNUNET_YES == clear_cls)
4031 { 3626 {
@@ -4036,7 +3631,6 @@ queue_destroy (struct MeshPeerQueue *queue, int clear_cls)
4036 GNUNET_break (GNUNET_YES == queue->tunnel->destroy); 3631 GNUNET_break (GNUNET_YES == queue->tunnel->destroy);
4037 /* fall through */ 3632 /* fall through */
4038 case GNUNET_MESSAGE_TYPE_MESH_UNICAST: 3633 case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
4039 case GNUNET_MESSAGE_TYPE_MESH_MULTICAST:
4040 case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: 3634 case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
4041 case GNUNET_MESSAGE_TYPE_MESH_ACK: 3635 case GNUNET_MESSAGE_TYPE_MESH_ACK:
4042 case GNUNET_MESSAGE_TYPE_MESH_POLL: 3636 case GNUNET_MESSAGE_TYPE_MESH_POLL:
@@ -4067,34 +3661,31 @@ queue_destroy (struct MeshPeerQueue *queue, int clear_cls)
4067 queue); 3661 queue);
4068 3662
4069 /* Delete from child_fc in the appropiate tunnel */ 3663 /* Delete from child_fc in the appropiate tunnel */
4070 max = queue->tunnel->fwd_queue_max; 3664// max = queue->tunnel->fwd_queue_max;
4071 GNUNET_PEER_resolve (queue->peer->id, &id); 3665// GNUNET_PEER_resolve (queue->peer->id, &id);
4072 cinfo = tunnel_get_neighbor_fc (queue->tunnel, &id); 3666// if (NULL != cinfo)
4073 if (NULL != cinfo) 3667// { FIXME
4074 { 3668// for (i = 0; i < cinfo->send_buffer_n; i++)
4075 for (i = 0; i < cinfo->send_buffer_n; i++) 3669// {
4076 { 3670// i2 = (cinfo->send_buffer_start + i) % max;
4077 unsigned int i2; 3671// if (cinfo->send_buffer[i2] == queue)
4078 i2 = (cinfo->send_buffer_start + i) % max; 3672// {
4079 if (cinfo->send_buffer[i2] == queue) 3673// /* Found corresponding entry in the send_buffer. Move all others back. */
4080 { 3674// unsigned int j;
4081 /* Found corresponding entry in the send_buffer. Move all others back. */ 3675//
4082 unsigned int j; 3676//
4083 unsigned int j2; 3677// for (j = i, j2 = 0, j3 = 0; j < cinfo->send_buffer_n - 1; j++)
4084 unsigned int j3; 3678// {
4085 3679// j2 = (cinfo->send_buffer_start + j) % max;
4086 for (j = i, j2 = 0, j3 = 0; j < cinfo->send_buffer_n - 1; j++) 3680// j3 = (cinfo->send_buffer_start + j + 1) % max;
4087 { 3681// cinfo->send_buffer[j2] = cinfo->send_buffer[j3];
4088 j2 = (cinfo->send_buffer_start + j) % max; 3682// }
4089 j3 = (cinfo->send_buffer_start + j + 1) % max; 3683//
4090 cinfo->send_buffer[j2] = cinfo->send_buffer[j3]; 3684// cinfo->send_buffer[j3] = NULL;
4091 } 3685// cinfo->send_buffer_n--;
4092 3686// }
4093 cinfo->send_buffer[j3] = NULL; 3687// }
4094 cinfo->send_buffer_n--; 3688// }
4095 }
4096 }
4097 }
4098 3689
4099 GNUNET_free (queue); 3690 GNUNET_free (queue);
4100} 3691}
@@ -4115,19 +3706,18 @@ struct MeshPeerQueue *
4115queue_get_next (const struct MeshPeerInfo *peer) 3706queue_get_next (const struct MeshPeerInfo *peer)
4116{ 3707{
4117 struct MeshPeerQueue *q; 3708 struct MeshPeerQueue *q;
4118 struct MeshTunnel *t; 3709
4119 struct MeshTransmissionDescriptor *info; 3710 struct MeshTransmissionDescriptor *info;
4120 struct MeshTunnelChildInfo *cinfo; 3711// struct GNUNET_MESH_Unicast *ucast;
4121 struct GNUNET_MESH_Unicast *ucast; 3712// struct GNUNET_MESH_ToOrigin *to_orig;
4122 struct GNUNET_MESH_ToOrigin *to_orig;
4123 struct GNUNET_PeerIdentity id; 3713 struct GNUNET_PeerIdentity id;
4124 uint32_t pid; 3714// uint32_t pid;
4125 uint32_t ack; 3715// uint32_t ack; FIXME
4126 3716
4127 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* selecting message\n"); 3717 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* selecting message\n");
4128 for (q = peer->queue_head; NULL != q; q = q->next) 3718 for (q = peer->queue_head; NULL != q; q = q->next)
4129 { 3719 {
4130 t = q->tunnel; 3720// t = q->tunnel;
4131 info = q->cls; 3721 info = q->cls;
4132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3722 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4133 "********* %s\n", 3723 "********* %s\n",
@@ -4135,36 +3725,35 @@ queue_get_next (const struct MeshPeerInfo *peer)
4135 switch (q->type) 3725 switch (q->type)
4136 { 3726 {
4137 case GNUNET_MESSAGE_TYPE_MESH_UNICAST: 3727 case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
4138 ucast = (struct GNUNET_MESH_Unicast *) info->mesh_data->data; 3728// ucast = (struct GNUNET_MESH_Unicast *) info->mesh_data->data;
4139 pid = ntohl (ucast->pid); 3729// pid = ntohl (ucast->pid);
4140 GNUNET_PEER_resolve (info->peer->id, &id); 3730 GNUNET_PEER_resolve (info->peer->id, &id);
4141 cinfo = tunnel_get_neighbor_fc(t, &id); 3731// ack = cinfo->fwd_ack;
4142 ack = cinfo->fwd_ack;
4143 break; 3732 break;
4144 case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: 3733 case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
4145 to_orig = (struct GNUNET_MESH_ToOrigin *) info->mesh_data->data; 3734// to_orig = (struct GNUNET_MESH_ToOrigin *) info->mesh_data->data;
4146 pid = ntohl (to_orig->pid); 3735// pid = ntohl (to_orig->pid);
4147 ack = t->bck_ack; 3736// ack = t->bck_ack;
4148 break; 3737 break;
4149 default: 3738 default:
4150 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3739 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4151 "********* OK!\n"); 3740 "********* OK!\n");
4152 return q; 3741 return q;
4153 } 3742 }
4154 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3743// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4155 "********* ACK: %u, PID: %u\n", 3744// "********* ACK: %u, PID: %u\n",
4156 ack, pid); 3745// ack, pid);
4157 if (GNUNET_NO == GMC_is_pid_bigger(pid, ack)) 3746// if (GNUNET_NO == GMC_is_pid_bigger(pid, ack))
4158 { 3747// {
4159 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3748// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4160 "********* OK!\n"); 3749// "********* OK!\n");
4161 return q; 3750// return q;
4162 } 3751// }
4163 else 3752// else
4164 { 3753// {
4165 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3754// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4166 "********* NEXT!\n"); 3755// "********* NEXT!\n");
4167 } 3756// }
4168 } 3757 }
4169 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3758 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4170 "********* nothing found\n"); 3759 "********* nothing found\n");
@@ -4188,12 +3777,10 @@ queue_send (void *cls, size_t size, void *buf)
4188 struct GNUNET_MessageHeader *msg; 3777 struct GNUNET_MessageHeader *msg;
4189 struct MeshPeerQueue *queue; 3778 struct MeshPeerQueue *queue;
4190 struct MeshTunnel *t; 3779 struct MeshTunnel *t;
4191 struct MeshTunnelChildInfo *cinfo;
4192 struct GNUNET_PeerIdentity dst_id; 3780 struct GNUNET_PeerIdentity dst_id;
4193 size_t data_size; 3781 size_t data_size;
4194 3782
4195 peer->core_transmit = NULL; 3783 peer->core_transmit = NULL;
4196 cinfo = NULL;
4197 3784
4198 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* Queue send\n"); 3785 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* Queue send\n");
4199 queue = queue_get_next (peer); 3786 queue = queue_get_next (peer);
@@ -4298,28 +3885,26 @@ queue_send (void *cls, size_t size, void *buf)
4298 { 3885 {
4299 case GNUNET_MESSAGE_TYPE_MESH_UNICAST: 3886 case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
4300 case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN: 3887 case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
4301 case GNUNET_MESSAGE_TYPE_MESH_MULTICAST: 3888// if (cinfo->send_buffer[cinfo->send_buffer_start] != queue)
4302 cinfo = tunnel_get_neighbor_fc (t, &dst_id); 3889// { FIXME
4303 if (cinfo->send_buffer[cinfo->send_buffer_start] != queue) 3890// GNUNET_break (0);
4304 { 3891// GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
4305 GNUNET_break (0); 3892// "at pos %u (%p) != %p\n",
4306 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3893// cinfo->send_buffer_start,
4307 "at pos %u (%p) != %p\n", 3894// cinfo->send_buffer[cinfo->send_buffer_start],
4308 cinfo->send_buffer_start, 3895// queue);
4309 cinfo->send_buffer[cinfo->send_buffer_start], 3896// }
4310 queue); 3897// if (cinfo->send_buffer_n > 0)
4311 } 3898// {
4312 if (cinfo->send_buffer_n > 0) 3899// cinfo->send_buffer[cinfo->send_buffer_start] = NULL;
4313 { 3900// cinfo->send_buffer_n--;
4314 cinfo->send_buffer[cinfo->send_buffer_start] = NULL; 3901// cinfo->send_buffer_start++;
4315 cinfo->send_buffer_n--; 3902// cinfo->send_buffer_start %= t->fwd_queue_max;
4316 cinfo->send_buffer_start++; 3903// }
4317 cinfo->send_buffer_start %= t->fwd_queue_max; 3904// else
4318 } 3905// {
4319 else 3906// GNUNET_break (0);
4320 { 3907// }
4321 GNUNET_break (0);
4322 }
4323 break; 3908 break;
4324 default: 3909 default:
4325 break; 3910 break;
@@ -4359,14 +3944,14 @@ queue_send (void *cls, size_t size, void *buf)
4359 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3944 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
4360 "********* %s stalled\n", 3945 "********* %s stalled\n",
4361 GNUNET_i2s(&my_full_id)); 3946 GNUNET_i2s(&my_full_id));
4362 if (NULL == cinfo) 3947// if (NULL == cinfo) FIXME
4363 cinfo = tunnel_get_neighbor_fc (t, &dst_id); 3948// cinfo = tunnel_get_neighbor_fc (t, &dst_id);
4364 // FIXME unify bck/fwd structures, bck does not have cinfo right now 3949// // FIXME unify bck/fwd structures, bck does not have cinfo right now
4365 if (NULL != cinfo && GNUNET_SCHEDULER_NO_TASK == cinfo->fc_poll) 3950// if (NULL != cinfo && GNUNET_SCHEDULER_NO_TASK == cinfo->fc_poll)
4366 { 3951// {
4367 cinfo->fc_poll = GNUNET_SCHEDULER_add_delayed (cinfo->fc_poll_time, 3952// cinfo->fc_poll = GNUNET_SCHEDULER_add_delayed (cinfo->fc_poll_time,
4368 &tunnel_poll, cinfo); 3953// &tunnel_poll, cinfo);
4369 } 3954// }
4370 } 3955 }
4371 } 3956 }
4372 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* return %d\n", data_size); 3957 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* return %d\n", data_size);
@@ -4396,11 +3981,9 @@ queue_add (void *cls, uint16_t type, size_t size,
4396 struct MeshPeerInfo *dst, struct MeshTunnel *t) 3981 struct MeshPeerInfo *dst, struct MeshTunnel *t)
4397{ 3982{
4398 struct MeshPeerQueue *queue; 3983 struct MeshPeerQueue *queue;
4399 struct MeshTunnelChildInfo *cinfo;
4400 struct GNUNET_PeerIdentity id; 3984 struct GNUNET_PeerIdentity id;
4401 unsigned int *max; 3985 unsigned int *max;
4402 unsigned int *n; 3986 unsigned int *n;
4403 unsigned int i;
4404 3987
4405 n = NULL; 3988 n = NULL;
4406 if (GNUNET_MESSAGE_TYPE_MESH_UNICAST == type || 3989 if (GNUNET_MESSAGE_TYPE_MESH_UNICAST == type ||
@@ -4450,26 +4033,25 @@ queue_add (void *cls, uint16_t type, size_t size,
4450 if (NULL == n) // Is this internal mesh traffic? 4033 if (NULL == n) // Is this internal mesh traffic?
4451 return; 4034 return;
4452 4035
4453 // It's payload, keep track of buffer per peer. 4036 // It's payload, keep track of buffer per peer. FIXME
4454 cinfo = tunnel_get_neighbor_fc(t, &id); 4037// i = (cinfo->send_buffer_start + cinfo->send_buffer_n) % t->fwd_queue_max;
4455 i = (cinfo->send_buffer_start + cinfo->send_buffer_n) % t->fwd_queue_max; 4038// if (NULL != cinfo->send_buffer[i])
4456 if (NULL != cinfo->send_buffer[i]) 4039// {
4457 { 4040// GNUNET_break (cinfo->send_buffer_n == t->fwd_queue_max); // aka i == start
4458 GNUNET_break (cinfo->send_buffer_n == t->fwd_queue_max); // aka i == start 4041// queue_destroy (cinfo->send_buffer[cinfo->send_buffer_start], GNUNET_YES);
4459 queue_destroy (cinfo->send_buffer[cinfo->send_buffer_start], GNUNET_YES); 4042// cinfo->send_buffer_start++;
4460 cinfo->send_buffer_start++; 4043// cinfo->send_buffer_start %= t->fwd_queue_max;
4461 cinfo->send_buffer_start %= t->fwd_queue_max; 4044// }
4462 } 4045// else
4463 else 4046// {
4464 { 4047// cinfo->send_buffer_n++;
4465 cinfo->send_buffer_n++; 4048// }
4466 } 4049// cinfo->send_buffer[i] = queue;
4467 cinfo->send_buffer[i] = queue; 4050// if (cinfo->send_buffer_n > t->fwd_queue_max)
4468 if (cinfo->send_buffer_n > t->fwd_queue_max) 4051// {
4469 { 4052// GNUNET_break (0);
4470 GNUNET_break (0); 4053// cinfo->send_buffer_n = t->fwd_queue_max;
4471 cinfo->send_buffer_n = t->fwd_queue_max; 4054// }
4472 }
4473} 4055}
4474 4056
4475 4057
@@ -4720,7 +4302,7 @@ handle_mesh_path_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
4720 else 4302 else
4721 send_client_tunnel_disconnect(t, NULL); 4303 send_client_tunnel_disconnect(t, NULL);
4722 4304
4723 tunnel_delete_peer (t, path->peers[path->length - 1]); 4305// tunnel_delete_peer (t, path->peers[path->length - 1]); FIXME
4724 path_destroy (path); 4306 path_destroy (path);
4725 return GNUNET_OK; 4307 return GNUNET_OK;
4726} 4308}
@@ -4807,7 +4389,7 @@ handle_mesh_tunnel_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
4807 { 4389 {
4808 unsigned int nc; 4390 unsigned int nc;
4809 4391
4810 tree_del_peer (t->tree, pid, &tunnel_child_removed, t); 4392// tree_del_peer (t->tree, pid, &tunnel_child_removed, t);
4811 nc = tree_count_children (t->tree); 4393 nc = tree_count_children (t->tree);
4812 if (nc > 0 || NULL != t->owner || t->nclients > 0) 4394 if (nc > 0 || NULL != t->owner || t->nclients > 0)
4813 { 4395 {
@@ -4846,7 +4428,6 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer,
4846{ 4428{
4847 struct GNUNET_MESH_Unicast *msg; 4429 struct GNUNET_MESH_Unicast *msg;
4848 struct GNUNET_PeerIdentity *neighbor; 4430 struct GNUNET_PeerIdentity *neighbor;
4849 struct MeshTunnelChildInfo *cinfo;
4850 struct MeshTunnel *t; 4431 struct MeshTunnel *t;
4851 GNUNET_PEER_Id dest_id; 4432 GNUNET_PEER_Id dest_id;
4852 uint32_t pid; 4433 uint32_t pid;
@@ -4926,11 +4507,9 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer,
4926 " not for us, retransmitting...\n"); 4507 " not for us, retransmitting...\n");
4927 4508
4928 neighbor = tree_get_first_hop (t->tree, dest_id); 4509 neighbor = tree_get_first_hop (t->tree, dest_id);
4929 cinfo = tunnel_get_neighbor_fc (t, neighbor); 4510
4930 cinfo->fwd_pid = pid; 4511/* cinfo->fwd_pid = pid; FIXME
4931 GNUNET_CONTAINER_multihashmap_iterate (t->children_fc, 4512
4932 &tunnel_add_skip,
4933 &neighbor);
4934 if (GNUNET_YES == t->nobuffer && 4513 if (GNUNET_YES == t->nobuffer &&
4935 GNUNET_YES == GMC_is_pid_bigger (pid, cinfo->fwd_ack)) 4514 GNUNET_YES == GMC_is_pid_bigger (pid, cinfo->fwd_ack))
4936 { 4515 {
@@ -4938,7 +4517,7 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer,
4938 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " %u > %u\n", pid, cinfo->fwd_ack); 4517 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " %u > %u\n", pid, cinfo->fwd_ack);
4939 GNUNET_break_op (0); 4518 GNUNET_break_op (0);
4940 return GNUNET_OK; 4519 return GNUNET_OK;
4941 } 4520 }*/
4942 send_prebuilt_message (message, neighbor, t); 4521 send_prebuilt_message (message, neighbor, t);
4943 GNUNET_STATISTICS_update (stats, "# unicast forwarded", 1, GNUNET_NO); 4522 GNUNET_STATISTICS_update (stats, "# unicast forwarded", 1, GNUNET_NO);
4944 return GNUNET_OK; 4523 return GNUNET_OK;
@@ -4963,7 +4542,6 @@ handle_mesh_data_to_orig (void *cls, const struct GNUNET_PeerIdentity *peer,
4963 struct GNUNET_PeerIdentity id; 4542 struct GNUNET_PeerIdentity id;
4964 struct MeshPeerInfo *peer_info; 4543 struct MeshPeerInfo *peer_info;
4965 struct MeshTunnel *t; 4544 struct MeshTunnel *t;
4966 struct MeshTunnelChildInfo *cinfo;
4967 GNUNET_PEER_Id predecessor; 4545 GNUNET_PEER_Id predecessor;
4968 size_t size; 4546 size_t size;
4969 uint32_t pid; 4547 uint32_t pid;
@@ -4993,26 +4571,20 @@ handle_mesh_data_to_orig (void *cls, const struct GNUNET_PeerIdentity *peer,
4993 return GNUNET_OK; 4571 return GNUNET_OK;
4994 } 4572 }
4995 4573
4996 cinfo = tunnel_get_neighbor_fc(t, peer);
4997 if (NULL == cinfo)
4998 {
4999 GNUNET_break (0);
5000 return GNUNET_OK;
5001 }
5002 4574
5003 if (cinfo->bck_pid == pid) 4575// if (cinfo->bck_pid == pid) FIXME
5004 { 4576// {
5005 /* already seen this packet, drop */ 4577// /* already seen this packet, drop */
5006 GNUNET_STATISTICS_update (stats, "# duplicate PID drops BCK", 1, GNUNET_NO); 4578// GNUNET_STATISTICS_update (stats, "# duplicate PID drops BCK", 1, GNUNET_NO);
5007 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4579// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5008 " Already seen pid %u, DROPPING!\n", pid); 4580// " Already seen pid %u, DROPPING!\n", pid);
5009 tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_ACK); 4581// tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_ACK);
5010 return GNUNET_OK; 4582// return GNUNET_OK;
5011 } 4583// }
5012 4584
5013 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4585 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5014 " pid %u not seen yet, forwarding\n", pid); 4586 " pid %u not seen yet, forwarding\n", pid);
5015 cinfo->bck_pid = pid; 4587// cinfo->bck_pid = pid; FIXME
5016 4588
5017 if (NULL != t->owner) 4589 if (NULL != t->owner)
5018 { 4590 {
@@ -5111,20 +4683,18 @@ handle_mesh_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
5111 /* Is this a forward or backward ACK? */ 4683 /* Is this a forward or backward ACK? */
5112 if (tree_get_predecessor(t->tree) != GNUNET_PEER_search(peer)) 4684 if (tree_get_predecessor(t->tree) != GNUNET_PEER_search(peer))
5113 { 4685 {
5114 struct MeshTunnelChildInfo *cinfo;
5115 4686
5116 debug_bck_ack++; 4687 debug_bck_ack++;
5117 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " FWD ACK\n"); 4688 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " FWD ACK\n");
5118 cinfo = tunnel_get_neighbor_fc (t, peer); 4689// cinfo->fwd_ack = ack; FIXME
5119 cinfo->fwd_ack = ack;
5120 tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_ACK); 4690 tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_ACK);
5121 tunnel_unlock_fwd_queues (t); 4691 tunnel_unlock_fwd_queues (t);
5122 if (GNUNET_SCHEDULER_NO_TASK != cinfo->fc_poll) 4692// if (GNUNET_SCHEDULER_NO_TASK != cinfo->fc_poll) FIXME
5123 { 4693// {
5124 GNUNET_SCHEDULER_cancel (cinfo->fc_poll); 4694// GNUNET_SCHEDULER_cancel (cinfo->fc_poll);
5125 cinfo->fc_poll = GNUNET_SCHEDULER_NO_TASK; 4695// cinfo->fc_poll = GNUNET_SCHEDULER_NO_TASK;
5126 cinfo->fc_poll_time = GNUNET_TIME_UNIT_SECONDS; 4696// cinfo->fc_poll_time = GNUNET_TIME_UNIT_SECONDS;
5127 } 4697// }
5128 } 4698 }
5129 else 4699 else
5130 { 4700 {
@@ -5172,11 +4742,8 @@ handle_mesh_poll (void *cls, const struct GNUNET_PeerIdentity *peer,
5172 /* Is this a forward or backward ACK? */ 4742 /* Is this a forward or backward ACK? */
5173 if (tree_get_predecessor(t->tree) != GNUNET_PEER_search(peer)) 4743 if (tree_get_predecessor(t->tree) != GNUNET_PEER_search(peer))
5174 { 4744 {
5175 struct MeshTunnelChildInfo *cinfo;
5176
5177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " from FWD\n"); 4745 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " from FWD\n");
5178 cinfo = tunnel_get_neighbor_fc (t, peer); 4746 /* FIXME cinfo->bck_ack = cinfo->fwd_pid; // mark as ready to send */
5179 cinfo->bck_ack = cinfo->fwd_pid; // mark as ready to send
5180 tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_POLL); 4747 tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_POLL);
5181 } 4748 }
5182 else 4749 else
@@ -5253,7 +4820,7 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
5253 if (tree_get_status (t->tree, peer_info->id) != MESH_PEER_READY) 4820 if (tree_get_status (t->tree, peer_info->id) != MESH_PEER_READY)
5254 { 4821 {
5255 tree_set_status (t->tree, peer_info->id, MESH_PEER_READY); 4822 tree_set_status (t->tree, peer_info->id, MESH_PEER_READY);
5256 send_client_peer_connected (t, peer_info->id); 4823// send_client_peer_connected (t, peer_info->id);
5257 } 4824 }
5258 if (NULL != peer_info->dhtget) 4825 if (NULL != peer_info->dhtget)
5259 { 4826 {