gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r30997 - gnunet/src/fs


From: gnunet
Subject: [GNUnet-SVN] r30997 - gnunet/src/fs
Date: Sat, 30 Nov 2013 18:26:45 +0100

Author: grothoff
Date: 2013-11-30 18:26:45 +0100 (Sat, 30 Nov 2013)
New Revision: 30997

Modified:
   gnunet/src/fs/gnunet-service-fs.h
   gnunet/src/fs/gnunet-service-fs_cp.c
   gnunet/src/fs/gnunet-service-fs_pr.c
Log:
fixing #3146: peer identities no longer have the size of hash codes; breaks FS 
protocol compatibility with previous versions slightly...

Modified: gnunet/src/fs/gnunet-service-fs.h
===================================================================
--- gnunet/src/fs/gnunet-service-fs.h   2013-11-30 15:09:03 UTC (rev 30996)
+++ gnunet/src/fs/gnunet-service-fs.h   2013-11-30 17:26:45 UTC (rev 30997)
@@ -83,7 +83,7 @@
 {
 
   /**
-   * Message type will be GNUNET_MESSAGE_TYPE_FS_GET.
+   * Message type will be #GNUNET_MESSAGE_TYPE_FS_GET.
    */
   struct GNUNET_MessageHeader header;
 
@@ -114,7 +114,7 @@
   /**
    * Which of the optional hash codes are present at the end of the
    * message?  See GET_MESSAGE_BIT_xx constants.  For each bit that is
-   * set, an additional struct GNUNET_HashCode with the respective content
+   * set, an additional `struct GNUNET_HashCode` with the respective content
    * (in order of the bits) will be appended to the end of the GET
    * message.
    */
@@ -126,7 +126,7 @@
    */
   struct GNUNET_HashCode query;
 
-  /* this is followed by hash codes as specified in the "hash_bitmap";
+  /* this is followed by PeerIdentities as specified in the "hash_bitmap";
    * after that, an optional bloomfilter (with bits set for replies
    * that should be suppressed) can be present */
 };

Modified: gnunet/src/fs/gnunet-service-fs_cp.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_cp.c        2013-11-30 15:09:03 UTC (rev 
30996)
+++ gnunet/src/fs/gnunet-service-fs_cp.c        2013-11-30 17:26:45 UTC (rev 
30997)
@@ -98,7 +98,7 @@
   struct GSF_ConnectedPeer *cp;
 
   /**
-   * Closure for 'gmc'.
+   * Closure for @e gmc.
    */
   void *gmc_cls;
 
@@ -108,7 +108,7 @@
   size_t size;
 
   /**
-   * GNUNET_YES if this is a query, GNUNET_NO for content.
+   * #GNUNET_YES if this is a query, #GNUNET_NO for content.
    */
   int is_query;
 
@@ -1116,7 +1116,7 @@
   uint16_t msize;
   const struct GetMessage *gm;
   unsigned int bits;
-  const struct GNUNET_HashCode *opt;
+  const struct GNUNET_PeerIdentity *opt;
   uint32_t bm;
   size_t bfsize;
   uint32_t ttl_decrement;
@@ -1146,13 +1146,13 @@
       bits++;
     bm >>= 1;
   }
-  if (msize < sizeof (struct GetMessage) + bits * sizeof (struct 
GNUNET_HashCode))
+  if (msize < sizeof (struct GetMessage) + bits * sizeof (struct 
GNUNET_PeerIdentity))
   {
     GNUNET_break_op (0);
     return NULL;
   }
-  opt = (const struct GNUNET_HashCode *) &gm[1];
-  bfsize = msize - sizeof (struct GetMessage) - bits * sizeof (struct 
GNUNET_HashCode);
+  opt = (const struct GNUNET_PeerIdentity *) &gm[1];
+  bfsize = msize - sizeof (struct GetMessage) - bits * sizeof (struct 
GNUNET_PeerIdentity);
   /* bfsize must be power of 2, check! */
   if (0 != ((bfsize - 1) & bfsize))
   {
@@ -1173,7 +1173,7 @@
     return NULL;
   }
   if (0 != (bm & GET_MESSAGE_BIT_RETURN_TO))
-    cp = GSF_peer_get_ ((const struct GNUNET_PeerIdentity *) &opt[bits++]);
+    cp = GSF_peer_get_ (&opt[bits++]);
   else
     cp = cps;
   if (NULL == cp)
@@ -1181,8 +1181,7 @@
     if (0 != (bm & GET_MESSAGE_BIT_RETURN_TO))
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Failed to find RETURN-TO peer `%4s' in connection set. 
Dropping query.\n",
-                  GNUNET_i2s ((const struct GNUNET_PeerIdentity *)
-                              &opt[bits - 1]));
+                  GNUNET_i2s (&opt[bits - 1]));
 
     else
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1209,12 +1208,13 @@
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received request for `%s' of type %u from peer `%4s' with flags 
%u\n",
-              GNUNET_h2s (&gm->query), (unsigned int) type, GNUNET_i2s (other),
+              GNUNET_h2s (&gm->query),
+              (unsigned int) type,
+              GNUNET_i2s (other),
               (unsigned int) bm);
   target =
       (0 !=
-       (bm & GET_MESSAGE_BIT_TRANSMIT_TO)) ? ((const struct GNUNET_PeerIdentity
-                                               *) &opt[bits++]) : NULL;
+       (bm & GET_MESSAGE_BIT_TRANSMIT_TO)) ? (&opt[bits++]) : NULL;
   options = GSF_PRO_DEFAULTS;
   spid = 0;
   if ((GNUNET_LOAD_get_load (cp->ppd.transmission_delay) > 3 * (1 + priority))

Modified: gnunet/src/fs/gnunet-service-fs_pr.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_pr.c        2013-11-30 15:09:03 UTC (rev 
30996)
+++ gnunet/src/fs/gnunet-service-fs_pr.c        2013-11-30 17:26:45 UTC (rev 
30997)
@@ -504,7 +504,7 @@
 {
   char lbuf[GNUNET_SERVER_MAX_MESSAGE_SIZE];
   struct GetMessage *gm;
-  struct GNUNET_HashCode *ext;
+  struct GNUNET_PeerIdentity *ext;
   size_t msize;
   unsigned int k;
   uint32_t bm;
@@ -537,7 +537,7 @@
     k++;
   }
   bf_size = GNUNET_CONTAINER_bloomfilter_get_size (pr->bf);
-  msize = sizeof (struct GetMessage) + bf_size + k * sizeof (struct 
GNUNET_HashCode);
+  msize = sizeof (struct GetMessage) + bf_size + k * sizeof (struct 
GNUNET_PeerIdentity);
   GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
   if (buf_size < msize)
     return msize;
@@ -561,16 +561,14 @@
   gm->filter_mutator = htonl (pr->mingle);
   gm->hash_bitmap = htonl (bm);
   gm->query = pr->public_data.query;
-  ext = (struct GNUNET_HashCode *) & gm[1];
+  ext = (struct GNUNET_PeerIdentity *) &gm[1];
   k = 0;
   if (!do_route)
     GNUNET_PEER_resolve (pr->sender_pid,
-                         (struct GNUNET_PeerIdentity *) &ext[k++]);
+                         &ext[k++]);
   if (NULL != pr->public_data.target)
-    memcpy (&ext[k++],
-           pr->public_data.target,
-           sizeof (struct GNUNET_PeerIdentity));
-  if (pr->bf != NULL)
+    ext[k++] = *pr->public_data.target;
+  if (NULL != pr->bf)
     GNUNET_assert (GNUNET_SYSERR !=
                    GNUNET_CONTAINER_bloomfilter_get_raw_data (pr->bf,
                                                               (char *) &ext[k],




reply via email to

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