changing heap remove node api to not pass heap; more fs hacking
authorChristian Grothoff <christian@grothoff.org>
Fri, 11 Mar 2011 16:58:27 +0000 (16:58 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 11 Mar 2011 16:58:27 +0000 (16:58 +0000)
17 files changed:
src/dht/gnunet-dht-driver.c
src/dht/gnunet-service-dht.c
src/dv/gnunet-service-dv.c
src/fs/gnunet-service-fs.c
src/fs/gnunet-service-fs.h
src/fs/gnunet-service-fs_pe.c
src/fs/gnunet-service-fs_pr.c
src/fs/gnunet-service-fs_pr.h
src/include/gnunet_container_lib.h
src/include/gnunet_mesh_service.h
src/mesh/mesh.h
src/mesh/mesh_api.c
src/util/Makefile.am
src/util/container_heap.c
src/util/test_container_heap.c
src/vpn/gnunet-daemon-exit.c
src/vpn/gnunet-daemon-vpn.c

index 7a1606219a744d3c8b88c6bcc22be609f3438cc1..d12cc91df0c64e163e0f454cc508b803a2c3d06b 100644 (file)
@@ -1243,10 +1243,8 @@ do_get(void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc);
 static int
 remove_peer_count(void *cls, const GNUNET_HashCode * key, void *value)
 {
-  struct FindPeerContext *find_peer_ctx = cls;
   struct PeerCount *peer_count = value;
-  GNUNET_CONTAINER_heap_remove_node (find_peer_ctx->peer_min_heap,
-                                     peer_count->heap_node);
+  GNUNET_CONTAINER_heap_remove_node (peer_count->heap_node);
   GNUNET_free(peer_count);
 
   return GNUNET_YES;
index e455cbc30d6c7a7f0d386b8e67ae591db6a4a14a..08cc7dc887fa897390bdecb87889f9cff0649a40 100644 (file)
@@ -2115,8 +2115,7 @@ remove_forward_entry (void *cls,
   struct DHTRouteSource *source_info = cls;
   struct DHTQueryRecord *record;
   source_info =
-    GNUNET_CONTAINER_heap_remove_node (forward_list.minHeap,
-                                       source_info->hnode);
+    GNUNET_CONTAINER_heap_remove_node (source_info->hnode);
   record = source_info->record;
   GNUNET_CONTAINER_DLL_remove (record->head, record->tail, source_info);
 
@@ -3733,7 +3732,7 @@ remove_recent (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   GNUNET_assert (GNUNET_YES ==
                  GNUNET_CONTAINER_multihashmap_remove (recent.hashmap, &hash,
                                                        req));
-  GNUNET_CONTAINER_heap_remove_node (recent.minHeap, req->heap_node);
+  GNUNET_CONTAINER_heap_remove_node (req->heap_node);
   GNUNET_CONTAINER_bloomfilter_free (req->bloom);
   GNUNET_free (req);
 
@@ -4241,7 +4240,7 @@ find_client_records (void *cls, const GNUNET_HashCode * key, void *value)
   if (pos != NULL)
     {
       GNUNET_CONTAINER_DLL_remove (record->head, record->tail, pos);
-      GNUNET_CONTAINER_heap_remove_node (forward_list.minHeap, pos->hnode);
+      GNUNET_CONTAINER_heap_remove_node (pos->hnode);
       if (pos->delete_task != GNUNET_SCHEDULER_NO_TASK)
        {
          GNUNET_SCHEDULER_cancel (pos->delete_task);
index 900c8f5d7a1d6a7272bc4ea21ab526053d106b8e..a6fe9762b3729dc35f1eccbacb54e5a0cc22630b 100644 (file)
@@ -2010,8 +2010,8 @@ distant_neighbor_free (struct DistantNeighbor *referee)
       GNUNET_CONTAINER_DLL_remove (referrer->referee_head,
                          referrer->referee_tail, referee);
     }
-  GNUNET_CONTAINER_heap_remove_node (neighbor_max_heap, referee->max_loc);
-  GNUNET_CONTAINER_heap_remove_node (neighbor_min_heap, referee->min_loc);
+  GNUNET_CONTAINER_heap_remove_node (referee->max_loc);
+  GNUNET_CONTAINER_heap_remove_node (referee->min_loc);
   GNUNET_CONTAINER_multihashmap_remove_all (extended_neighbors,
                                     &referee->identity.hashPubKey);
   GNUNET_free_non_null (referee->pkey);
index 1016981607e8dd4cadaac979cb2690f483c4db4e..ab16bc8343da4ac33c974cd0ac5e2f2bf1c448f6 100644 (file)
@@ -1532,8 +1532,7 @@ destroy_pending_request (struct PendingRequest *pr)
 
   if (pr->hnode != NULL)
     {
-      GNUNET_CONTAINER_heap_remove_node (requests_by_expiration_heap,
-                                        pr->hnode);
+      GNUNET_CONTAINER_heap_remove_node (pr->hnode);
       pr->hnode = NULL;
     }
   if (NULL == pr->client_request_list)
index a82206e9c5eb69d046e47daa4741889ad6affd90..ee4cea8e23322fb964907bc1434b5fd618afb0a4 100644 (file)
@@ -70,6 +70,10 @@ struct GSF_PendingRequest;
  */
 struct GSF_LocalClient;
 
+/**
+ * Information kept per plan per request ('pe' module).
+ */
+struct GSF_RequestPlan;
 
 /**
  * Our connection to the datastore.
index e7608653ed739e4af00a37a9904316b6658cb473..306bb948c657a8d65c6643c58bcddf7dda5e3396 100644 (file)
 #include "gnunet-service-fs_pe.h"
 #include "gnunet-service-fs_pr.h"
 
+
+/**
+ * Information we keep per request per peer.  This is a doubly-linked
+ * list (with head and tail in the 'struct GSF_PendingRequestData')
+ * with one entry in each heap of each 'struct PeerPlan'.  Each
+ * entry tracks information relevant for this request and this peer.
+ */
+struct GSF_RequestPlan
+{
+
+  /**
+   * This is a doubly-linked list.
+   */
+  struct GSF_RequestPlan *next;
+
+  /**
+   * This is a doubly-linked list.
+   */
+  struct GSF_RequestPlan *prev;
+
+  /**
+   * Heap node associated with this request and this peer.
+   */
+  struct GNUNET_CONTAINER_HeapNode *hn;
+
+  /**
+   * Associated pending request.
+   */
+  struct GSF_PendingRequest *pr;
+
+  /**
+   * Earliest time we'd be happy to transmit this request.
+   */
+  struct GNUNET_TIME_Absolute earliest_transmission;
+
+};
+
+
 /**
  * Transmission plan for a peer.
  */
 struct PeerPlan
 {
   /**
-   * Heap with pending queries, smaller weights mean higher priority.
+   * Heap with pending queries (struct GSF_RequestPlan), smaller weights mean higher priority.
    */
   struct GNUNET_CONTAINER_Heap *heap;
 
@@ -61,6 +99,28 @@ struct PeerPlan
 static struct GNUNET_CONTAINER_MultiHashMap *plans;
 
 
+/**
+ * Insert the given request plan into the heap with the appropriate weight.
+ *
+ * @param pp associated peer's plan
+ * @param rp request to plan
+ */
+static void
+plan (struct PeerPlan *pp,
+      struct GSF_RequestPlan *rp)
+{
+  GNUNET_CONTAINER_HeapCostType weight;
+  struct GSF_PendingRequestData *prd;
+
+  prd = GSF_pending_request_get_data_ (rp->pr);
+  weight = 0; // FIXME: calculate real weight!
+  // FIXME: calculate 'rp->earliest_transmission'!
+  rp->hn = GNUNET_CONTAINER_heap_insert (pp->heap,
+                                        rp,
+                                        weight);
+}
+
+
 /**
  * Figure out when and how to transmit to the given peer.
  *
@@ -86,7 +146,7 @@ transmit_message_callback (void *cls,
                           void *buf)
 {
   struct PeerPlan *pp = cls;
-  struct GSF_PendingRequest *pr;
+  struct GSF_RequestPlan *rp;
   size_t msize;
 
   if (NULL == buf)
@@ -95,8 +155,8 @@ transmit_message_callback (void *cls,
       pp->task = GNUNET_SCHEDULER_add_now (&schedule_peer_transmission, pp);
       return 0;
     }
-  pr = GNUNET_CONTAINER_heap_peek (pp->heap);
-  msize = GSF_pending_request_get_message_ (pr, buf_size, buf);
+  rp = GNUNET_CONTAINER_heap_peek (pp->heap);
+  msize = GSF_pending_request_get_message_ (rp->pr, buf_size, buf);
   if (msize > buf_size)
     {
       /* buffer to small (message changed), try again */
@@ -104,8 +164,9 @@ transmit_message_callback (void *cls,
       return 0;
     }
   /* remove from root, add again elsewhere... */
-  GNUNET_assert (pr == GNUNET_CONTAINER_heap_remove_root (pp->heap));
-  GSF_plan_add_ (pp->cp, pr);
+  GNUNET_assert (rp == GNUNET_CONTAINER_heap_remove_root (pp->heap));
+  rp->hn = NULL;
+  plan (pp, rp);
   return msize;
 }
 
@@ -121,7 +182,8 @@ schedule_peer_transmission (void *cls,
                            const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct PeerPlan *pp = cls;
-  struct GSF_PendingRequest *pr;
+  struct GSF_RequestPlan *rp;
+  struct GSF_PendingRequestData *prd;
   size_t msize;
   struct GNUNET_TIME_Relative delay;
 
@@ -131,17 +193,17 @@ schedule_peer_transmission (void *cls,
   if (0 == GNUNET_CONTAINER_heap_get_size (pp->heap))
     return;
   GNUNET_assert (NULL == pp->pth);
-  pr = GNUNET_CONTAINER_heap_peek (pp->heap);
-  if (0) // FIXME: if (re)transmission should wait, wait...
+  rp = GNUNET_CONTAINER_heap_peek (pp->heap);
+  prd = GSF_pending_request_get_data_ (rp->pr);
+  delay = GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission);
+  if (delay.rel_value > 0)
     {
-      delay = GNUNET_TIME_UNIT_SECONDS;
-      // FIXME
       pp->task = GNUNET_SCHEDULER_add_delayed (delay,
                                               &schedule_peer_transmission,
                                               pp);
       return;
     }
-  msize = GSF_pending_request_get_message_ (pr, 0, NULL);                                         
+  msize = GSF_pending_request_get_message_ (rp->pr, 0, NULL);                                     
   pp->pth = GSF_peer_transmit_ (pp->cp,
                                GNUNET_YES,
                                0 /* FIXME: pr->priority? */,
@@ -165,7 +227,8 @@ GSF_plan_add_ (const struct GSF_ConnectedPeer *cp,
 {
   struct GNUNET_PeerIdentity id;
   struct PeerPlan *pp;
-  GNUNET_CONTAINER_HeapCostType weight;
+  struct GSF_PendingRequestData *prd;
+  struct GSF_RequestPlan *rp;
   
   GSF_connected_peer_get_identity_ (cp, &id);
   pp = GNUNET_CONTAINER_multihashmap_get (plans,
@@ -179,13 +242,16 @@ GSF_plan_add_ (const struct GSF_ConnectedPeer *cp,
                                         pp,
                                         GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
     }
-  weight = 0; // FIXME: calculate real weight!
-  GNUNET_CONTAINER_heap_insert (pp->heap,
-                               pr,
-                               weight);
+  prd = GSF_pending_request_get_data_ (pr);
+  rp = GNUNET_malloc (sizeof (struct GSF_RequestPlan));
+  rp->pr = pr;
+  GNUNET_CONTAINER_DLL_insert (prd->rp_head,
+                              prd->rp_tail,
+                              rp);
+  plan (pp, rp);
   if (pp->pth != NULL)
     {
-      if (pr != GNUNET_CONTAINER_heap_peek (pp->heap))
+      if (rp != GNUNET_CONTAINER_heap_peek (pp->heap))
        return;
       GSF_peer_transmit_cancel_ (pp->pth);
       pp->pth = NULL;
@@ -208,6 +274,8 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp)
 {
   struct GNUNET_PeerIdentity id;
   struct PeerPlan *pp;
+  struct GSF_RequestPlan *rp;
+  struct GSF_PendingRequestData *prd;
 
   GSF_connected_peer_get_identity_ (cp, &id);
   pp = GNUNET_CONTAINER_multihashmap_get (plans,
@@ -219,101 +287,40 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp)
     GSF_peer_transmit_cancel_ (pp->pth);
   if (GNUNET_SCHEDULER_NO_TASK != pp->task)
     GNUNET_SCHEDULER_cancel (pp->task);
-  GNUNET_CONTAINER_heap_destroy (pp->heap);
-  GNUNET_free (pp);
-}
-
-
-/**
- * Closure for 'find_request'.
- */
-struct FindRequestClosure
-{
-  /**
-   * Place to store the node that was found (NULL for none).
-   */
-  struct GNUNET_CONTAINER_HeapNode *node;
-
-  /**
-   * Value we're looking for
-   */
-  const struct GSF_PendingRequest *pr;
-};
-
-
-/**
- * Find a heap node where the value matches the
- * pending request given in the closure.
- *
- * @param cls the 'struct FindRequestClosure'
- * @param node heap structure we're looking for on a match
- * @param element the pending request stored in the heap
- * @param cost weight of the request
- * @return GNUNET_YES to continue looking
- */
-static int
-find_request (void *cls,
-             struct GNUNET_CONTAINER_HeapNode *node,
-             void *element,
-             GNUNET_CONTAINER_HeapCostType cost)
-{
-  struct FindRequestClosure *frc = cls;
-  struct GSF_PendingRequest *pr = element;
-
-  if (pr == frc->pr)
-    {
-      frc->node = node;
-      return GNUNET_NO;
-    }
-  return GNUNET_YES;
-}
-
-
-/**
- * Remove the given request from all heaps. * FIXME: O(n) -- inefficient!
- *
- * @param cls 'struct GSF_PendingRequest' to purge
- * @param key identity of the peer we're currently looking at (unused)
- * @param value PeerPlan for the given peer to search for the 'cls'
- * @return GNUNET_OK (continue iteration)
- */
-static int
-remove_request (void *cls,
-               const GNUNET_HashCode *key,
-               void *value)
-{
-  const struct GSF_PendingRequest *pr = cls;
-  struct PeerPlan *pp = value;
-  struct GNUNET_CONTAINER_Heap *h = pp->heap;
-  struct FindRequestClosure frc;
-
-  frc.pr = pr;
-  do
+  while (NULL != (rp = GNUNET_CONTAINER_heap_remove_root (pp->heap)))
     {
-      frc.node = NULL;
-      GNUNET_CONTAINER_heap_iterate (h, &find_request, &frc);
-      if (frc.node != NULL)
-       GNUNET_CONTAINER_heap_remove_node (h, frc.node);
+      prd = GSF_pending_request_get_data_ (rp->pr);
+      GNUNET_CONTAINER_DLL_remove (prd->rp_head,
+                                  prd->rp_tail,
+                                  rp);
+      GNUNET_free (rp);
     }
-  while (NULL != frc.node);
-  return GNUNET_OK;
+  GNUNET_CONTAINER_heap_destroy (pp->heap);
+  GNUNET_free (pp);
 }
 
 
 /**
  * Notify the plan about a request being done; destroy all entries
- * associated with this request.  Note that this implementation is
- * currently terribly inefficient (O(n)) and could instead be done in
- * O(1).  But for now, I first want to see it work correctly...
+ * associated with this request.
  *
  * @param pr request that is done
  */
 void
 GSF_plan_notify_request_done_ (const struct GSF_PendingRequest *pr)
 {
-  GNUNET_CONTAINER_multihashmap_iterate (plans,
-                                        &remove_request,
-                                        (void*) pr);
+  struct GSF_RequestPlan *rp;
+  struct GSF_PendingRequestData *prd;
+
+  while (NULL != (rp = prd->rp_head))
+    {
+      prd = GSF_pending_request_get_data_ (rp->pr);
+      GNUNET_CONTAINER_heap_remove_node (rp->hn);
+      GNUNET_CONTAINER_DLL_remove (prd->rp_head,
+                                  prd->rp_tail,
+                                  rp);
+      GNUNET_free (rp);
+    }
 }
 
 
index ff2f7a3a3e6ef984016d9338fb48a4e83d145ed5..2c983eaed3839b486f76d5662a5dac469b97ab4f 100644 (file)
@@ -526,8 +526,7 @@ clean_request (void *cls,
     GNUNET_CONTAINER_bloomfilter_free (pr->bf);
   GNUNET_PEER_change_rc (pr->sender_pid, -1);
   if (NULL != pr->hnode)
-    GNUNET_CONTAINER_heap_remove_node (requests_by_expiration_heap,
-                                      pr->hnode);
+    GNUNET_CONTAINER_heap_remove_node (pr->hnode);
   if (NULL != pr->qe)
     GNUNET_DATASTORE_cancel (pr->qe);
   if (NULL != pr->gh)
index 9632df015985c901c89f028a09eafe98b18d2edd..5759bee4af0dc1a3e234a4631be6f9f028fcf311 100644 (file)
@@ -91,6 +91,16 @@ struct GSF_PendingRequestData
    */
   struct GNUNET_PeerIdentity target;
 
+  /**
+   * Fields for the plan module to track a DLL with the request.
+   */
+  struct GSF_RequestPlan *rp_head;
+
+  /**
+   * Fields for the plan module to track a DLL with the request.
+   */
+  struct GSF_RequestPlan *rp_tail;
+
   /**
    * Current TTL for the request.
    */
index 41ed4bd3fb283f8b96de40a2c5b634b70ce4759e..6b7016c74290bba80e159fd4e855efc1ce584f60 100644 (file)
@@ -1011,8 +1011,7 @@ GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap);
  * @return element data stored at the node, NULL if heap is empty
  */
 void *
-GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_Heap *heap,
-                                  struct GNUNET_CONTAINER_HeapNode *node);
+GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_HeapNode *node);
 
 
 /**
index 1677c714cc0676bac78ebee1f9b8ae1fe819e516..738811950239459dbb327d4e5d9f66b4ad076c15 100644 (file)
@@ -61,6 +61,7 @@ struct GNUNET_MESH_Tunnel;
  * @param cls closure (set from GNUNET_MESH_connect)
  * @param tunnel connection to the other end
  * @param tunnel_ctx place to store local state associated with the tunnel
+ * @param sender who sent the message
  * @param message the actual message
  * @param atsi performance data for the connection
  * @return GNUNET_OK to keep the connection open,
@@ -69,7 +70,8 @@ struct GNUNET_MESH_Tunnel;
 typedef int
   (*GNUNET_MESH_MessageCallback) (void *cls,
                                   struct GNUNET_MESH_Tunnel *tunnel,
-                                 void **tunnel_ctx,
+                                 void **tunnel_ctx, 
+                                 const struct GNUNET_PeerIdentity *sender,
                                   const struct GNUNET_MessageHeader *message,
                                  const struct GNUNET_TRANSPORT_ATS_Information *atsi);
 
@@ -248,6 +250,18 @@ GNUNET_MESH_peer_request_connect_add (struct GNUNET_MESH_Tunnel *tunnel,
                                      const struct GNUNET_PeerIdentity *peer);
 
 
+/**
+ * Request that a peer should be removed from the tunnel.  The existing
+ * disconnect handler will be called ONCE if we were connected.
+ *
+ * @param tunnel handle to existing tunnel
+ * @param peer peer to remove
+ */
+void
+GNUNET_MESH_peer_request_connect_del (struct GNUNET_MESH_Tunnel *tunnel,
+                                     const struct GNUNET_PeerIdentity *peer);
+
+
 /**
  * Request that the mesh should try to connect to a peer supporting the given
  * message type.
@@ -300,6 +314,7 @@ struct GNUNET_MESH_TransmitHandle;
  * @param cork is corking allowed for this transmission?
  * @param priority how important is the message?
  * @param maxdelay how long can the message wait?
+ * @param target destination for the message, NULL for multicast to all tunnel targets 
  * @param notify_size how many bytes of buffer space does notify want?
  * @param notify function to call when buffer space is available;
  *        will be called with NULL on timeout or if the overall queue
@@ -319,6 +334,7 @@ GNUNET_MESH_notify_transmit_ready (struct
                                   struct
                                   GNUNET_TIME_Relative
                                   maxdelay,
+                                  // const struct GNUNET_PeerIdentity *target,
                                   size_t
                                   notify_size,
                                   GNUNET_CONNECTION_TransmitReadyNotify
index 085f3ef4d63c6f5f0ff4308148e89117ba8a5a1c..e51b0c890e50a4b250a7c6b91e39fe020e643029 100644 (file)
 /**
  * @author Bartlomiej Polot
  * @file mesh/mesh.h
+ *
+ * TODO:
+ * - soft stateing (keep-alive (CHANGE?) / timeout / disconnect) -- not a message issue
+ * - error reporting (CREATE/CHANGE/ADD/DEL?) -- new message!
+ * - partial disconnect reporting -- same as error reporting?
+ * - add vs create? change vs. keep-alive? same msg or different ones? -- thinking...
+ * - speed requirement specification (change?) in mesh API -- API call
+ *
+ * - API messages!
  */
 
 
 struct GNUNET_MESH_ManipulatePath
 {
     /**
-     * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_[CREATE|CHANGE|ADD]
+     * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_[CREATE|CHANGE|ADD|DEL]
+     *
+     * Size: sizeof(struct GNUNET_MESH_ManipulatePath) + path_length * sizeof (struct GNUNET_PeerIdentity)
      */
     struct GNUNET_MessageHeader header;
 
     /**
-     * Id of the tunnel this path belongs to
+     * Id of the tunnel this path belongs to, unique in conjunction with the origin.
      */
-    uint32_t tid;
+    uint32_t tid GNUNET_PACKED;
 
     /**
-     * Information about speed requirements
+     * Information about speed requirements.  If the tunnel cannot sustain the 
+     * minimum bandwidth, packets are to be dropped.
      */
-    uint32_t speed_min;
-    uint32_t speed_max;
+    uint32_t speed_min GNUNET_PACKED;
 
     /**
-     * Number of hops in the path given below
+     * path_length structs defining the *whole* path from the origin [0] to the
+     * final destination [path_length-1].
      */
-    uint16_t path_length;
+  // struct GNUNET_PeerIdentity peers[path_length];
+};
 
+/**
+ * Message for mesh data traffic to all tunnel targets.
+ */
+struct GNUNET_MESH_OriginMulticast
+{
     /**
-     * path_length structs defining the *whole* path
+     * Type: GNUNET_MESSAGE_TYPE_DATA_MULTICAST
+     */
+    struct GNUNET_MessageHeader header;
+
+    /**
+     * TID of the tunnel
+     */
+    uint32_t tid GNUNET_PACKED;
+
+    /**
+     * OID of the tunnel
+     */
+    struct GNUNET_PeerIdentity oid;
+
+    /**
+     * FIXME: Some form of authentication
+     */
+    // uint32_t token;
+
+    /**
+     * Payload follows
      */
-    struct GNUNET_PeerIdentity peers[];
 };
 
+
 /**
- * Message for mesh data traffic
+ * Message for mesh data traffic to a particular destination from origin.
  */
-struct GNUNET_MESH_Data
+struct GNUNET_MESH_DataMessageFromOrigin
 {
     /**
-     * Type: GNUNET_MESSAGE_TYPE_DATA_[GO|BACK]
+     * Type: GNUNET_MESSAGE_TYPE_DATA_MESSAGE_FROM_ORIGIN
      */
     struct GNUNET_MessageHeader header;
 
+    /**
+     * TID of the tunnel
+     */
+    uint32_t tid GNUNET_PACKED;
+
     /**
      * OID of the tunnel
      */
     struct GNUNET_PeerIdentity oid;
 
+    /**
+     * Destination.
+     */
+    struct GNUNET_PeerIdentity destination;
+
+    /**
+     * FIXME: Some form of authentication
+     */
+    // uint32_t token;
+
+    /**
+     * Payload follows
+     */
+};
+
+
+/**
+ * Message for mesh data traffic from a tunnel participant to origin.
+ */
+struct GNUNET_MESH_DataMessageToOrigin
+{
+    /**
+     * Type: GNUNET_MESSAGE_TYPE_DATA_MESSAGE_TO_ORIGIN
+     */
+    struct GNUNET_MessageHeader header;
+
     /**
      * TID of the tunnel
      */
-    uint32_t tid;
+    uint32_t tid GNUNET_PACKED;
 
     /**
-     * FIXME Some form of authentication
+     * OID of the tunnel
      */
-    uint32_t token;
+    struct GNUNET_PeerIdentity oid;
 
     /**
-     * Size of payload
-     * FIXME uint16 enough?
+     * Sender of the message.
      */
-    uint16_t size;
+    struct GNUNET_PeerIdentity sender;
 
     /**
-     * Payload
+     * FIXME: Some form of authentication
+     */
+    // uint32_t token;
+
+    /**
+     * Payload follows
      */
-    uint8_t data[];
 };
 
 /**
@@ -109,24 +181,20 @@ struct GNUNET_MESH_SpeedNotify
     struct GNUNET_MessageHeader header;
 
     /**
-     * OID of the tunnel
+     * TID of the tunnel
      */
-    struct GNUNET_PeerIdentity oid;
+    uint32_t tid GNUNET_PACKED;
 
     /**
-     * TID of the tunnel
+     * OID of the tunnel
      */
-    uint32_t tid;
+    struct GNUNET_PeerIdentity oid;
 
     /**
-     * Slowest link down the path
+     * Slowest link down the path (above minimum speed requirement).
      */
     uint32_t speed_min;
 
-    /**
-     * Fastest link down the path
-     */
-    uint32_t speed_max;
 };
 
-#endif
\ No newline at end of file
+#endif
index f539312cf7166b66b54b712a1f2138bce3f9f984..053449fbe20c851e4cd2e853abc5de7f9f0dd4b8 100644 (file)
@@ -315,7 +315,7 @@ core_receive (void *cls,
     }
 
   return handler->callback (handle->cls, &tunnel->tunnel,
-                           &tunnel->tunnel.ctx, rmessage, atsi);
+                           &tunnel->tunnel.ctx, other, rmessage, atsi);
 }
 
 
index 9b43b5f0564b26883c526217772473a407b94fac..b24b3ab7cffa6ed416d49605810054ed0f924bca 100644 (file)
@@ -92,7 +92,7 @@ gnunet_service_resolver_LDADD = \
   $(GN_LIBINTL)
 gnunet_service_resolver_DEPENDENCIES = \
   libgnunetutil.la
-       
+
 
 gnunet_resolver_SOURCES = \
  gnunet-resolver.c         
@@ -229,7 +229,8 @@ test_crypto_aes_LDADD = \
 test_crypto_aes_weak_SOURCES = \
  test_crypto_aes_weak.c
 test_crypto_aes_weak_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la  
+ $(top_builddir)/src/util/libgnunetutil.la  \
+ -lgcrypt
 
 test_crypto_crc_SOURCES = \
  test_crypto_crc.c
index 7cd30a0a740c784a04d90fd1f172ac1b59dd2c8b..c332cdd63da68c9843efc21cded890f32320bc7c 100644 (file)
  */
 struct GNUNET_CONTAINER_HeapNode
 {
+  /**
+   * Heap this node belongs to.
+   */
+  struct GNUNET_CONTAINER_Heap *heap;
+
   /**
    * Parent node.
    */
@@ -340,6 +345,7 @@ GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap,
   struct GNUNET_CONTAINER_HeapNode *node;
 
   node = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_HeapNode));
+  node->heap = heap;
   node->element = element;
   node->cost = cost;
   heap->size++;
@@ -405,10 +411,10 @@ GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap)
  * 'size' field of the tree.
  */
 static void
-remove_node (struct GNUNET_CONTAINER_Heap *heap,
-            struct GNUNET_CONTAINER_HeapNode *node)
+remove_node (struct GNUNET_CONTAINER_HeapNode *node)
 {
   struct GNUNET_CONTAINER_HeapNode *ancestor;
+  struct GNUNET_CONTAINER_Heap *heap = node->heap;
 
   /* update 'size' of the ancestors */
   ancestor = node;
@@ -471,20 +477,20 @@ remove_node (struct GNUNET_CONTAINER_Heap *heap,
 /**
  * Removes a node from the heap.
  * 
- * @param heap heap to modify
  * @param node node to remove
  * @return element data stored at the node
  */
 void *
-GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_Heap *heap,
-                                   struct GNUNET_CONTAINER_HeapNode *node)
+GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_HeapNode *node)
 {
   void *ret;
+  struct GNUNET_CONTAINER_Heap *heap;
+
+  heap = node->heap; 
   CHECK (heap->root);
   if (heap->walk_pos == node)
     (void) GNUNET_CONTAINER_heap_walk_get_next (heap);
-  remove_node (heap, node);
+  remove_node (node);
   heap->size--;
   ret = node->element;
   if (heap->walk_pos == node)
@@ -518,7 +524,7 @@ GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap,
                  (heap->size == heap->root->tree_size + 1) );
   CHECK (heap->root);
 #endif
-  remove_node (heap, node);
+  remove_node (node);
 #if DEBUG
   CHECK (heap->root);
   GNUNET_assert ( ( (heap->size == 1) && 
index 87bc49129deed6e922317f19979edbfd243180cb..6a0d5d68db06330d3e14923ad3454b0a78c621ad 100644 (file)
@@ -93,7 +93,7 @@ check ()
   n2 = GNUNET_CONTAINER_heap_insert (myHeap, "78", 78);
   GNUNET_assert (2 == GNUNET_CONTAINER_heap_get_size (myHeap));
   GNUNET_assert (0 == strcmp ("78",
-                             GNUNET_CONTAINER_heap_remove_node (myHeap, n2)));
+                             GNUNET_CONTAINER_heap_remove_node (n2)));
   GNUNET_assert (1 == GNUNET_CONTAINER_heap_get_size (myHeap));
   GNUNET_CONTAINER_heap_iterate (myHeap, &iterator_callback, NULL);
   
@@ -110,13 +110,13 @@ check ()
   n5 = GNUNET_CONTAINER_heap_insert (myHeap, "100", 100);
   n6 = GNUNET_CONTAINER_heap_insert (myHeap, "30/200", 30);
   GNUNET_assert (5 == GNUNET_CONTAINER_heap_get_size (myHeap));
-  GNUNET_CONTAINER_heap_remove_node (myHeap, n5);
+  GNUNET_CONTAINER_heap_remove_node (n5);
   r = GNUNET_CONTAINER_heap_remove_root (myHeap); /* n1 */
   GNUNET_assert (NULL != r);
   GNUNET_assert (0 == strcmp ("11",
                              r));
   GNUNET_CONTAINER_heap_update_cost (myHeap, n6, 200);
-  GNUNET_CONTAINER_heap_remove_node (myHeap, n3); 
+  GNUNET_CONTAINER_heap_remove_node (n3); 
   r = GNUNET_CONTAINER_heap_remove_root (myHeap); /* n4 */
   GNUNET_assert (NULL != r);
   GNUNET_assert (0 == strcmp ("50",
@@ -137,7 +137,7 @@ check ()
   n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
   GNUNET_CONTAINER_heap_update_cost (myHeap, n1, 15);
   
-  r = GNUNET_CONTAINER_heap_remove_node (myHeap,n1);
+  r = GNUNET_CONTAINER_heap_remove_node (n1);
   GNUNET_assert (NULL != r);
   GNUNET_assert (0 == strcmp ("10", r));
   
@@ -145,10 +145,10 @@ check ()
   n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
 
   GNUNET_CONTAINER_heap_walk_get_next (myHeap);
-  r = GNUNET_CONTAINER_heap_remove_node (myHeap,n2);
+  r = GNUNET_CONTAINER_heap_remove_node (n2);
   GNUNET_assert (NULL != r);
   GNUNET_assert (0 == strcmp ("20", r));
-  r = GNUNET_CONTAINER_heap_remove_node (myHeap,n1);
+  r = GNUNET_CONTAINER_heap_remove_node (n1);
   GNUNET_assert (NULL != r);
   GNUNET_assert (0 == strcmp ("10", r));
   
@@ -156,8 +156,8 @@ check ()
   n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
   n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 10);
   
-  GNUNET_CONTAINER_heap_remove_node (myHeap,n2);
-  GNUNET_CONTAINER_heap_remove_node (myHeap,n1);  
+  GNUNET_CONTAINER_heap_remove_node (n2);
+  GNUNET_CONTAINER_heap_remove_node (n1);  
   r = GNUNET_CONTAINER_heap_remove_root (myHeap); 
   GNUNET_assert (NULL != r);
   GNUNET_assert (0 == strcmp ("30", r));
@@ -166,9 +166,9 @@ check ()
   n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
   n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 10);
 
-  GNUNET_CONTAINER_heap_remove_node (myHeap,n2);
-  GNUNET_CONTAINER_heap_remove_node (myHeap,n1);  
-  r = GNUNET_CONTAINER_heap_remove_node (myHeap, n3); 
+  GNUNET_CONTAINER_heap_remove_node (n2);
+  GNUNET_CONTAINER_heap_remove_node (n1);  
+  r = GNUNET_CONTAINER_heap_remove_node ( n3); 
   GNUNET_assert (NULL != r);
   GNUNET_assert (0 == strcmp ("30", r));
   
@@ -176,7 +176,7 @@ check ()
   n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 20);
   n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 30);
   
-  GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2)));
+  GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (n2)));
   GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_root (myHeap)));  
   GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_root (myHeap)));  
   
@@ -191,11 +191,11 @@ check ()
   n7 = GNUNET_CONTAINER_heap_insert (myHeap, "70", 10);
   n8 = GNUNET_CONTAINER_heap_insert (myHeap, "80", 10);  
   
-  GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (myHeap,n3)));
+  GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (n3)));
   
   // Cleaning up...
-  GNUNET_assert (0 == nstrcmp ("60", GNUNET_CONTAINER_heap_remove_node (myHeap,n6)));   
-  GNUNET_assert (0 == nstrcmp ("50", GNUNET_CONTAINER_heap_remove_node (myHeap,n5)));
+  GNUNET_assert (0 == nstrcmp ("60", GNUNET_CONTAINER_heap_remove_node (n6)));   
+  GNUNET_assert (0 == nstrcmp ("50", GNUNET_CONTAINER_heap_remove_node (n5)));
   
   // Testing heap_walk_get_next
   GNUNET_CONTAINER_heap_walk_get_next (myHeap);
@@ -204,11 +204,11 @@ check ()
   GNUNET_CONTAINER_heap_walk_get_next (myHeap);
   GNUNET_CONTAINER_heap_walk_get_next (myHeap);  
   
-  GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1)));
-  GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2)));  
-  GNUNET_assert (0 == nstrcmp ("40", GNUNET_CONTAINER_heap_remove_node (myHeap,n4)));
-  GNUNET_assert (0 == nstrcmp ("70", GNUNET_CONTAINER_heap_remove_node (myHeap,n7)));  
-  GNUNET_assert (0 == nstrcmp ("80", GNUNET_CONTAINER_heap_remove_node (myHeap,n8)));
+  GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (n1)));
+  GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (n2)));  
+  GNUNET_assert (0 == nstrcmp ("40", GNUNET_CONTAINER_heap_remove_node (n4)));
+  GNUNET_assert (0 == nstrcmp ("70", GNUNET_CONTAINER_heap_remove_node (n7)));  
+  GNUNET_assert (0 == nstrcmp ("80", GNUNET_CONTAINER_heap_remove_node (n8)));
   
   // End Testing remove_node
  
@@ -220,30 +220,30 @@ check ()
   n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
   GNUNET_CONTAINER_heap_update_cost (myHeap, n1, 15);
   
-  GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1)));
+  GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (n1)));
   
   n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
   n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
 
   GNUNET_CONTAINER_heap_walk_get_next (myHeap);
-  GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2)));
-  GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1))); 
+  GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (n2)));
+  GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (n1))); 
   
   n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);  
   n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
   n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 10);
   
-  GNUNET_CONTAINER_heap_remove_node (myHeap,n2);
-  GNUNET_CONTAINER_heap_remove_node (myHeap,n1);  
+  GNUNET_CONTAINER_heap_remove_node (n2);
+  GNUNET_CONTAINER_heap_remove_node (n1);  
   GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_root (myHeap)));
   
   n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
   n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 10);
   n3 = GNUNET_CONTAINER_heap_insert (myHeap, "30", 10);
 
-  GNUNET_CONTAINER_heap_remove_node (myHeap,n2);
-  GNUNET_CONTAINER_heap_remove_node (myHeap,n1);  
-  GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (myHeap,n3)));
+  GNUNET_CONTAINER_heap_remove_node (n2);
+  GNUNET_CONTAINER_heap_remove_node (n1);  
+  GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (n3)));
   
   n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
   n2 = GNUNET_CONTAINER_heap_insert (myHeap, "20", 20);
@@ -256,11 +256,11 @@ check ()
   n7 = GNUNET_CONTAINER_heap_insert (myHeap, "70", 10);
   n8 = GNUNET_CONTAINER_heap_insert (myHeap, "80", 10);  
   
-  GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (myHeap,n3)));
+  GNUNET_assert (0 == nstrcmp ("30", GNUNET_CONTAINER_heap_remove_node (n3)));
   
   // Cleaning up...
-  GNUNET_assert (0 == nstrcmp ("60", GNUNET_CONTAINER_heap_remove_node (myHeap,n6)));   
-  GNUNET_assert (0 == nstrcmp ("50", GNUNET_CONTAINER_heap_remove_node (myHeap,n5)));
+  GNUNET_assert (0 == nstrcmp ("60", GNUNET_CONTAINER_heap_remove_node (n6)));   
+  GNUNET_assert (0 == nstrcmp ("50", GNUNET_CONTAINER_heap_remove_node (n5)));
   
   // Testing heap_walk_get_next
   GNUNET_CONTAINER_heap_walk_get_next (myHeap);
@@ -269,11 +269,11 @@ check ()
   GNUNET_CONTAINER_heap_walk_get_next (myHeap);
   GNUNET_CONTAINER_heap_walk_get_next (myHeap);  
   
-  GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (myHeap,n1)));
-  GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (myHeap,n2)));  
-  GNUNET_assert (0 == nstrcmp ("40", GNUNET_CONTAINER_heap_remove_node (myHeap,n4)));
-  GNUNET_assert (0 == nstrcmp ("70", GNUNET_CONTAINER_heap_remove_node (myHeap,n7)));  
-  GNUNET_assert (0 == nstrcmp ("80", GNUNET_CONTAINER_heap_remove_node (myHeap,n8)));
+  GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (n1)));
+  GNUNET_assert (0 == nstrcmp ("20", GNUNET_CONTAINER_heap_remove_node (n2)));  
+  GNUNET_assert (0 == nstrcmp ("40", GNUNET_CONTAINER_heap_remove_node (n4)));
+  GNUNET_assert (0 == nstrcmp ("70", GNUNET_CONTAINER_heap_remove_node (n7)));  
+  GNUNET_assert (0 == nstrcmp ("80", GNUNET_CONTAINER_heap_remove_node (n8)));
   
   // End Testing remove_node
  
index f6198894fd9cf5e0c130c10ef95cfc2b6bb9c1f8..03e9831c8936e097f284a4d1e46c9b3536f093a1 100644 (file)
@@ -447,6 +447,7 @@ static int
 receive_udp_service (void *cls,
                      struct GNUNET_MESH_Tunnel *tunnel,
                      void **tunnel_ctx,
+                    const struct GNUNET_PeerIdentity *sender,
                      const struct GNUNET_MessageHeader *message,
                      const struct GNUNET_TRANSPORT_ATS_Information *atsi)
 {
index 50c9d14b1ea21f0345b769998c63c1808b40f208..4d6a569f490724d9f1cbf02dd25be3b77f4a889d 100644 (file)
@@ -418,6 +418,7 @@ add_additional_port (struct map_entry *me, uint16_t port)
 static int
 receive_udp_back (void *cls, struct GNUNET_MESH_Tunnel* tunnel,
                  void **tunnel_ctx,
+                 const struct GNUNET_PeerIdentity *sender,
                  const struct GNUNET_MessageHeader *message,
                  const struct GNUNET_TRANSPORT_ATS_Information *atsi)
 {