gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r1119 - GNUnet/src/applications/fs/module


From: grothoff
Subject: [GNUnet-SVN] r1119 - GNUnet/src/applications/fs/module
Date: Tue, 28 Jun 2005 13:27:51 -0700 (PDT)

Author: grothoff
Date: 2005-06-28 13:27:46 -0700 (Tue, 28 Jun 2005)
New Revision: 1119

Added:
   GNUnet/src/applications/fs/module/anonymity.c
   GNUnet/src/applications/fs/module/anonymity.h
Modified:
   GNUnet/src/applications/fs/module/Makefile.am
   GNUnet/src/applications/fs/module/fs.c
   GNUnet/src/applications/fs/module/migration.c
Log:
fixing more fixmes

Modified: GNUnet/src/applications/fs/module/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/module/Makefile.am       2005-06-28 20:16:36 UTC 
(rev 1118)
+++ GNUnet/src/applications/fs/module/Makefile.am       2005-06-28 20:27:46 UTC 
(rev 1119)
@@ -7,6 +7,7 @@
 
 
 libgnunetmodule_fs_la_SOURCES = \
+  anonymity.c anonymity.h \
   fs.c \
   ondemand.c ondemand.h \
   migration.c migration.h \

Added: GNUnet/src/applications/fs/module/anonymity.c
===================================================================
--- GNUnet/src/applications/fs/module/anonymity.c       2005-06-28 20:16:36 UTC 
(rev 1118)
+++ GNUnet/src/applications/fs/module/anonymity.c       2005-06-28 20:27:46 UTC 
(rev 1119)
@@ -0,0 +1,88 @@
+/*
+     This file is part of GNUnet.
+     (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other 
contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file applications/fs/module/anonymity.c
+ * @brief code for checking if cover traffic is sufficient
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "anonymity.h"
+#include "gnunet_protocols.h"
+
+/**
+ * consider traffic volume before sending out content.
+ * ok, so this is not 100% clean since it kind-of
+ * belongs into the gap code (since it is concerned
+ * with anonymity and GAP messages).  So we should
+ * probably move it below the callback by passing
+ * the anonymity level along.  But that would
+ * require changing the DataProcessor somewhat,
+ * which would also be ugly.  So to keep things
+ * simple, we do the anonymity-level check for
+ * outgoing content right here. 
+ *
+ * @return OK if cover traffic is sufficient
+ */
+int checkCoverTraffic(Traffic_ServiceAPI * traffic,
+                     unsigned int level) {
+  unsigned int count;
+  unsigned int peers;
+  unsigned int sizes;
+  unsigned int timevect;
+
+  if (level == 0)
+    return OK;
+  if (traffic == NULL)
+    return SYSERR;
+  if (OK != traffic->get(5 * cronSECONDS / TRAFFIC_TIME_UNIT, /* 
TTL_DECREMENT/TTU */
+                        GAP_p2p_PROTO_RESULT,
+                        TC_RECEIVED,
+                        &count,
+                        &peers,
+                        &sizes,
+                        &timevect)) {
+    LOG(LOG_WARNING,
+       _("Failed to get traffic stats.\n"));
+    return SYSERR;
+  }
+  if (level > 1000) {
+    if (peers < level / 1000) {
+      LOG(LOG_DEBUG,
+         "Not enough cover traffic to satisfy anonymity requirements. Result 
dropped.\n");      
+      return SYSERR;
+    }
+    if (count < level % 1000) {
+      LOG(LOG_DEBUG,
+         "Not enough cover traffic to satisfy anonymity requirements. Result 
dropped.\n");
+      return SYSERR;
+    }
+  } else {
+    if (count < level) {
+      LOG(LOG_DEBUG,
+         "Not enough cover traffic to satisfy anonymity requirements. Result 
dropped.\n");      
+      return SYSERR;
+    }
+  }
+  return OK;
+}
+                     
+/* end of anonymity.c */

Added: GNUnet/src/applications/fs/module/anonymity.h
===================================================================
--- GNUnet/src/applications/fs/module/anonymity.h       2005-06-28 20:16:36 UTC 
(rev 1118)
+++ GNUnet/src/applications/fs/module/anonymity.h       2005-06-28 20:27:46 UTC 
(rev 1119)
@@ -0,0 +1,49 @@
+/*
+     This file is part of GNUnet.
+     (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other 
contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file applications/fs/module/anonymity.h
+ * @brief code for checking if cover traffic is sufficient
+ * @author Christian Grothoff
+ */
+
+#ifndef ANONYMITY_H
+#define ANONYMITY_H
+
+#include "gnunet_traffic_service.h"
+
+/**
+ * consider traffic volume before sending out content.
+ * ok, so this is not 100% clean since it kind-of
+ * belongs into the gap code (since it is concerned
+ * with anonymity and GAP messages).  So we should
+ * probably move it below the callback by passing
+ * the anonymity level along.  But that would
+ * require changing the DataProcessor somewhat,
+ * which would also be ugly.  So to keep things
+ * simple, we do the anonymity-level check for
+ * outgoing content right here. 
+ *
+ * @return OK if cover traffic is sufficient
+ */
+int checkCoverTraffic(Traffic_ServiceAPI * traffic,
+                     unsigned int level);
+
+#endif

Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c      2005-06-28 20:16:36 UTC (rev 
1118)
+++ GNUnet/src/applications/fs/module/fs.c      2005-06-28 20:27:46 UTC (rev 
1119)
@@ -607,6 +607,7 @@
   cron_t now;
   const Datastore_Value * value;
   Datastore_Value * xvalue;
+  unsigned int level;
 
   if (ntohl(invalue->type) == ONDEMAND_BLOCK) {
     if (OK != ONDEMAND_getIndexed(datastore,
@@ -639,67 +640,16 @@
     ntohl(value->size) -
     sizeof(Datastore_Value);
 
-  if (ntohl(value->anonymityLevel) != 0) {
-    /* consider traffic volume before migrating;
-       ok, so this is not 100% clean since it kind-of
-       belongs into the gap code (since it is concerned
-       with anonymity and GAP messages).  So we should
-       probably move it below the callback by passing
-       the anonymity level along.  But that would
-       require changing the DataProcessor somewhat,
-       which would also be ugly.  So to keep things
-       simple, we do the anonymity-level check for
-       outgoing content right here. */
-    if (traffic != NULL) {
-      unsigned int level;
-      unsigned int count;
-      unsigned int peers;
-      unsigned int sizes;
-      unsigned int timevect;
-
-      level = ntohl(value->anonymityLevel) - 1;
-      if (OK != traffic->get(5 * cronSECONDS / TRAFFIC_TIME_UNIT, /* 
TTL_DECREMENT/TTU */
-                            GAP_p2p_PROTO_RESULT,
-                            TC_RECEIVED,
-                            &count,
-                            &peers,
-                            &sizes,
-                            &timevect)) {
-       LOG(LOG_WARNING,
-           _("Failed to get traffic stats.\n"));
-       FREENONNULL(xvalue);
-       return OK;
-      }
-      if (level > 1000) {
-       if (peers < level / 1000) {
-         LOG(LOG_DEBUG,
-             "Not enough cover traffic to satisfy anonymity requirements. 
Result dropped.\n");
-         FREENONNULL(xvalue);
-         return OK;
-       }
-       if (count < level % 1000) {
-         LOG(LOG_DEBUG,
-             "Not enough cover traffic to satisfy anonymity requirements. 
Result dropped.\n");
-         FREENONNULL(xvalue);
-         return OK;
-       }
-      } else {
-       if (count < level) {
-         LOG(LOG_DEBUG,
-             "Not enough cover traffic to satisfy anonymity requirements. 
Result dropped.\n");
-         FREENONNULL(xvalue);
-         return OK;
-       }
-      }
-    } else {
-      /* traffic required by module not loaded;
-        refuse to hand out data that requires
-        anonymity! */
-      FREENONNULL(xvalue);
-      return OK;
-    }
+  level
+    = ntohl(value->anonymityLevel);
+  if (OK != checkCoverTraffic(traffic,
+                             level)) {
+    /* traffic required by module not loaded;
+       refuse to hand out data that requires
+       anonymity! */
+    FREENONNULL(xvalue);
+    return OK;    
   }
-
   gw = MALLOC(size);
   gw->dc.size = htonl(size);
   et = ntohll(value->expirationTime);

Modified: GNUnet/src/applications/fs/module/migration.c
===================================================================
--- GNUnet/src/applications/fs/module/migration.c       2005-06-28 20:16:36 UTC 
(rev 1118)
+++ GNUnet/src/applications/fs/module/migration.c       2005-06-28 20:27:46 UTC 
(rev 1119)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2003 Christian Grothoff (and other contributing authors)
+     (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other 
contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -19,7 +19,7 @@
 */
 
 /**
- * @file applications/afs/module/migration.c
+ * @file applications/fs/module/migration.c
  * @brief This module is responsible for pushing content out
  * into the network.
  * @author Christian Grothoff
@@ -100,24 +100,17 @@
     anonymity = ntohl(content->anonymityLevel);
     ret = SYSERR;
     if (anonymity == 0) {
-      /* ret = OK; */
+      /* ret = OK; (if DHT succeeds) fixme for DHT */
     } 
     if ( (ret != OK) &&
-        (traffic != NULL) ) {
+        (OK == checkCoverTraffic(traffic,
+                                 anonymity)) ) {
       gw = MALLOC(size);
       gw->dc.size = htonl(size);
       gw->timeout = htonll(et);
       memcpy(&gw[1],
             &content[1],
             size - sizeof(GapWrapper));
-
-      
-      
-    
-      /* FIXME: check anonymity level,
-        if 0, consider using DHT migration instead;
-        if high, consider traffic volume before
-        migrating */
       ret = gap->tryMigrate(&gw->dc,
                            &key,
                            position,





reply via email to

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