gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r14630 - in gnunet/src: dht dv fs include mesh util vpn


From: gnunet
Subject: [GNUnet-SVN] r14630 - in gnunet/src: dht dv fs include mesh util vpn
Date: Fri, 11 Mar 2011 17:58:27 +0100

Author: grothoff
Date: 2011-03-11 17:58:27 +0100 (Fri, 11 Mar 2011)
New Revision: 14630

Modified:
   gnunet/src/dht/gnunet-dht-driver.c
   gnunet/src/dht/gnunet-service-dht.c
   gnunet/src/dv/gnunet-service-dv.c
   gnunet/src/fs/gnunet-service-fs.c
   gnunet/src/fs/gnunet-service-fs.h
   gnunet/src/fs/gnunet-service-fs_pe.c
   gnunet/src/fs/gnunet-service-fs_pr.c
   gnunet/src/fs/gnunet-service-fs_pr.h
   gnunet/src/include/gnunet_container_lib.h
   gnunet/src/include/gnunet_mesh_service.h
   gnunet/src/mesh/mesh.h
   gnunet/src/mesh/mesh_api.c
   gnunet/src/util/Makefile.am
   gnunet/src/util/container_heap.c
   gnunet/src/util/test_container_heap.c
   gnunet/src/vpn/gnunet-daemon-exit.c
   gnunet/src/vpn/gnunet-daemon-vpn.c
Log:
changing heap remove node api to not pass heap; more fs hacking

Modified: gnunet/src/dht/gnunet-dht-driver.c
===================================================================
--- gnunet/src/dht/gnunet-dht-driver.c  2011-03-11 16:23:52 UTC (rev 14629)
+++ gnunet/src/dht/gnunet-dht-driver.c  2011-03-11 16:58:27 UTC (rev 14630)
@@ -1243,10 +1243,8 @@
 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;

Modified: gnunet/src/dht/gnunet-service-dht.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht.c 2011-03-11 16:23:52 UTC (rev 14629)
+++ gnunet/src/dht/gnunet-service-dht.c 2011-03-11 16:58:27 UTC (rev 14630)
@@ -2115,8 +2115,7 @@
   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 @@
   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 @@
   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);

Modified: gnunet/src/dv/gnunet-service-dv.c
===================================================================
--- gnunet/src/dv/gnunet-service-dv.c   2011-03-11 16:23:52 UTC (rev 14629)
+++ gnunet/src/dv/gnunet-service-dv.c   2011-03-11 16:58:27 UTC (rev 14630)
@@ -2010,8 +2010,8 @@
       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);

Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c   2011-03-11 16:23:52 UTC (rev 14629)
+++ gnunet/src/fs/gnunet-service-fs.c   2011-03-11 16:58:27 UTC (rev 14630)
@@ -1532,8 +1532,7 @@
 
   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)

Modified: gnunet/src/fs/gnunet-service-fs.h
===================================================================
--- gnunet/src/fs/gnunet-service-fs.h   2011-03-11 16:23:52 UTC (rev 14629)
+++ gnunet/src/fs/gnunet-service-fs.h   2011-03-11 16:58:27 UTC (rev 14630)
@@ -70,6 +70,10 @@
  */
 struct GSF_LocalClient;
 
+/**
+ * Information kept per plan per request ('pe' module).
+ */
+struct GSF_RequestPlan;
 
 /**
  * Our connection to the datastore.

Modified: gnunet/src/fs/gnunet-service-fs_pe.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_pe.c        2011-03-11 16:23:52 UTC (rev 
14629)
+++ gnunet/src/fs/gnunet-service-fs_pe.c        2011-03-11 16:58:27 UTC (rev 
14630)
@@ -28,13 +28,51 @@
 #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;
 
@@ -62,6 +100,28 @@
 
 
 /**
+ * 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.
  *
  * @param cls the 'struct GSF_ConnectedPeer' for transmission
@@ -86,7 +146,7 @@
                           void *buf)
 {
   struct PeerPlan *pp = cls;
-  struct GSF_PendingRequest *pr;
+  struct GSF_RequestPlan *rp;
   size_t msize;
 
   if (NULL == buf)
@@ -95,8 +155,8 @@
       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 @@
       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 @@
                            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 @@
   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 @@
 {
   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 @@
                                         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 @@
 {
   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_peer_transmit_cancel_ (pp->pth);
   if (GNUNET_SCHEDULER_NO_TASK != pp->task)
     GNUNET_SCHEDULER_cancel (pp->task);
+  while (NULL != (rp = GNUNET_CONTAINER_heap_remove_root (pp->heap)))
+    {
+      prd = GSF_pending_request_get_data_ (rp->pr);
+      GNUNET_CONTAINER_DLL_remove (prd->rp_head,
+                                  prd->rp_tail,
+                                  rp);
+      GNUNET_free (rp);
+    }
   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
-    {
-      frc.node = NULL;
-      GNUNET_CONTAINER_heap_iterate (h, &find_request, &frc);
-      if (frc.node != NULL)
-       GNUNET_CONTAINER_heap_remove_node (h, frc.node);
-    }
-  while (NULL != frc.node);
-  return GNUNET_OK;
-}
-
-
-/**
  * 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);
+    }
 }
 
 

Modified: gnunet/src/fs/gnunet-service-fs_pr.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_pr.c        2011-03-11 16:23:52 UTC (rev 
14629)
+++ gnunet/src/fs/gnunet-service-fs_pr.c        2011-03-11 16:58:27 UTC (rev 
14630)
@@ -526,8 +526,7 @@
     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)

Modified: gnunet/src/fs/gnunet-service-fs_pr.h
===================================================================
--- gnunet/src/fs/gnunet-service-fs_pr.h        2011-03-11 16:23:52 UTC (rev 
14629)
+++ gnunet/src/fs/gnunet-service-fs_pr.h        2011-03-11 16:58:27 UTC (rev 
14630)
@@ -92,6 +92,16 @@
   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.
    */
   struct GNUNET_TIME_Absolute ttl;

Modified: gnunet/src/include/gnunet_container_lib.h
===================================================================
--- gnunet/src/include/gnunet_container_lib.h   2011-03-11 16:23:52 UTC (rev 
14629)
+++ gnunet/src/include/gnunet_container_lib.h   2011-03-11 16:58:27 UTC (rev 
14630)
@@ -1011,8 +1011,7 @@
  * @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);
 
 
 /**

Modified: gnunet/src/include/gnunet_mesh_service.h
===================================================================
--- gnunet/src/include/gnunet_mesh_service.h    2011-03-11 16:23:52 UTC (rev 
14629)
+++ gnunet/src/include/gnunet_mesh_service.h    2011-03-11 16:58:27 UTC (rev 
14630)
@@ -61,6 +61,7 @@
  * @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 @@
 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);
 
@@ -249,6 +251,18 @@
 
 
 /**
+ * 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 @@
  * @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 @@
                                   struct
                                   GNUNET_TIME_Relative
                                   maxdelay,
+                                  // const struct GNUNET_PeerIdentity *target,
                                   size_t
                                   notify_size,
                                   GNUNET_CONNECTION_TransmitReadyNotify

Modified: gnunet/src/mesh/mesh.h
===================================================================
--- gnunet/src/mesh/mesh.h      2011-03-11 16:23:52 UTC (rev 14629)
+++ gnunet/src/mesh/mesh.h      2011-03-11 16:58:27 UTC (rev 14630)
@@ -21,6 +21,15 @@
 /**
  * @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!
  */
 
 
@@ -35,67 +44,130 @@
 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_PeerIdentity peers[];
+    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
+     */
 };
 
+
 /**
- * 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
      */
-    uint8_t data[];
+    // uint32_t token;
+
+    /**
+     * Payload follows
+     */
 };
 
 /**
@@ -109,24 +181,20 @@
     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

Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c  2011-03-11 16:23:52 UTC (rev 14629)
+++ gnunet/src/mesh/mesh_api.c  2011-03-11 16:58:27 UTC (rev 14630)
@@ -315,7 +315,7 @@
     }
 
   return handler->callback (handle->cls, &tunnel->tunnel,
-                           &tunnel->tunnel.ctx, rmessage, atsi);
+                           &tunnel->tunnel.ctx, other, rmessage, atsi);
 }
 
 

Modified: gnunet/src/util/Makefile.am
===================================================================
--- gnunet/src/util/Makefile.am 2011-03-11 16:23:52 UTC (rev 14629)
+++ gnunet/src/util/Makefile.am 2011-03-11 16:58:27 UTC (rev 14630)
@@ -92,8 +92,8 @@
   $(GN_LIBINTL)
 gnunet_service_resolver_DEPENDENCIES = \
   libgnunetutil.la
-       
 
+
 gnunet_resolver_SOURCES = \
  gnunet-resolver.c         
 gnunet_resolver_LDADD = \
@@ -229,7 +229,8 @@
 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

Modified: gnunet/src/util/container_heap.c
===================================================================
--- gnunet/src/util/container_heap.c    2011-03-11 16:23:52 UTC (rev 14629)
+++ gnunet/src/util/container_heap.c    2011-03-11 16:58:27 UTC (rev 14630)
@@ -37,6 +37,11 @@
 struct GNUNET_CONTAINER_HeapNode
 {
   /**
+   * Heap this node belongs to.
+   */
+  struct GNUNET_CONTAINER_Heap *heap;
+
+  /**
    * Parent node.
    */
   struct GNUNET_CONTAINER_HeapNode *parent;
@@ -340,6 +345,7 @@
   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 @@
  * '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 @@
 /**
  * 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 @@
                  (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) && 

Modified: gnunet/src/util/test_container_heap.c
===================================================================
--- gnunet/src/util/test_container_heap.c       2011-03-11 16:23:52 UTC (rev 
14629)
+++ gnunet/src/util/test_container_heap.c       2011-03-11 16:58:27 UTC (rev 
14630)
@@ -93,7 +93,7 @@
   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 @@
   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 @@
   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 @@
   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 @@
   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 @@
   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 @@
   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 @@
   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 @@
   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 @@
   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 @@
   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 @@
   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
  

Modified: gnunet/src/vpn/gnunet-daemon-exit.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-exit.c 2011-03-11 16:23:52 UTC (rev 14629)
+++ gnunet/src/vpn/gnunet-daemon-exit.c 2011-03-11 16:58:27 UTC (rev 14630)
@@ -447,6 +447,7 @@
 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)
 {

Modified: gnunet/src/vpn/gnunet-daemon-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn.c  2011-03-11 16:23:52 UTC (rev 14629)
+++ gnunet/src/vpn/gnunet-daemon-vpn.c  2011-03-11 16:58:27 UTC (rev 14630)
@@ -418,6 +418,7 @@
 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)
 {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]