gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r4058 - in GNUnet/src: applications/dht/module applications


From: grothoff
Subject: [GNUnet-SVN] r4058 - in GNUnet/src: applications/dht/module applications/dht/tools applications/fs/module include
Date: Tue, 26 Dec 2006 21:35:21 -0800 (PST)

Author: grothoff
Date: 2006-12-26 21:35:16 -0800 (Tue, 26 Dec 2006)
New Revision: 4058

Added:
   GNUnet/src/include/dht.h
Removed:
   GNUnet/src/applications/dht/module/dht.h
   GNUnet/src/include/gnunet_dht.h
Modified:
   GNUnet/src/applications/dht/module/cs.c
   GNUnet/src/applications/dht/tools/dht-query.c
   GNUnet/src/applications/dht/tools/dht_api.c
   GNUnet/src/applications/fs/module/fs.c
   GNUnet/src/include/Makefile.am
   GNUnet/src/include/gnunet_dht_lib.h
   GNUnet/src/include/gnunet_dht_service.h
Log:
DHT API cleanup

Modified: GNUnet/src/applications/dht/module/cs.c
===================================================================
--- GNUnet/src/applications/dht/module/cs.c     2006-12-27 05:21:35 UTC (rev 
4057)
+++ GNUnet/src/applications/dht/module/cs.c     2006-12-27 05:35:16 UTC (rev 
4058)
@@ -30,7 +30,7 @@
 #include "gnunet_core.h"
 #include "gnunet_protocols.h"
 #include "gnunet_rpc_service.h"
-#include "gnunet_dht.h"
+#include "dht.h"
 #include "gnunet_dht_service.h"
 
 /**

Deleted: GNUnet/src/applications/dht/module/dht.h
===================================================================
--- GNUnet/src/applications/dht/module/dht.h    2006-12-27 05:21:35 UTC (rev 
4057)
+++ GNUnet/src/applications/dht/module/dht.h    2006-12-27 05:35:16 UTC (rev 
4058)
@@ -1,35 +0,0 @@
-/*
-     This file is part of GNUnet
-     Copyright (C) 2004, 2005, 2006 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 module/dht.h
- * @brief Core file of DHT-module for GNUnet p2p framework.
- * @author Marko R�ih�
- * @version dht.h,v 1.20 2004/05/10 22:28:53 mjraiha Exp
- */
-
-#ifndef DHT_H
-#define DHT_H
-
-#include "gnunet_dht.h"
-#include "gnunet_core.h"
-#include "platform.h"
-
-#endif
-

Modified: GNUnet/src/applications/dht/tools/dht-query.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht-query.c       2006-12-27 05:21:35 UTC 
(rev 4057)
+++ GNUnet/src/applications/dht/tools/dht-query.c       2006-12-27 05:35:16 UTC 
(rev 4058)
@@ -32,10 +32,6 @@
 #include "gnunet_util_boot.h"
 #include "gnunet_util_network_client.h"
 
-static DHT_TableId table;
-
-static char * table_id;
-
 static unsigned int timeout;
 
 static struct GE_Context * ectx;
@@ -49,12 +45,9 @@
  */
 static struct CommandLineOption gnunetqueryOptions[] = {
   COMMAND_LINE_OPTION_CFG_FILE(&cfgFilename), /* -c */
-  COMMAND_LINE_OPTION_HELP(gettext_noop("Query (get KEY, put KEY VALUE) a DHT 
table.")), /* -h */
+  COMMAND_LINE_OPTION_HELP(gettext_noop("Query (get KEY, put KEY VALUE) DHT 
table.")), /* -h */
   COMMAND_LINE_OPTION_HOSTNAME, /* -H */
   COMMAND_LINE_OPTION_LOGGING, /* -L */
-  { 't', "table", "NAME",
-    gettext_noop("join table called NAME"),
-    1, &gnunet_getopt_configure_set_string, &table_id },
   { 'T', "timeout", "TIME",
     gettext_noop("allow TIME ms to process each command"),
     1, &gnunet_getopt_configure_set_uint, &timeout },
@@ -89,10 +82,7 @@
         "get", key);
   ret = DHT_LIB_get(cfg,
                    ectx,
-                   &table,
                    DHT_STRING2STRING_BLOCK,
-                   1, /* prio */
-                   1, /* key count */
                    &hc,
                    timeout,
                    &printCallback,
@@ -118,12 +108,13 @@
   GE_LOG(ectx,
         GE_DEBUG | GE_REQUEST | GE_USER,
         "Issuing '%s(%s,%s)' command.\n",
-        "put", key, value);
+        "put",
+        key,
+        value);
   if (OK == DHT_LIB_put(cfg,
                        ectx,
-                       &table,
                        &hc,
-                       1, /* prio */
+                       DHT_STRING2STRING_BLOCK,
                        timeout,
                        dc)) {
     printf(_("'%s(%s,%s)' succeeded\n"),
@@ -141,9 +132,7 @@
         char * const * argv) {
   int i;
   struct ClientServerConnection * handle;
-  HashCode512 table;
 
-
   i = GNUNET_init(argc,
                  argv,
                  "gnunet-dht-query",
@@ -155,19 +144,6 @@
     GNUNET_fini(ectx, cfg);
     return -1;
   }
-  if (table_id == NULL) {
-    printf(_("No table name specified, using `%s'.\n"),
-          "test");
-    table_id = STRDUP("test");
-  }
-  if (OK != enc2hash(table_id,
-                    &table)) {
-    hash(table_id,
-        strlen(table_id),
-        &table);
-  }
-  FREE(table_id);
-  table_id = NULL;
 
   handle = client_connection_create(ectx, cfg);
   if (handle == NULL) {

Modified: GNUnet/src/applications/dht/tools/dht_api.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht_api.c 2006-12-27 05:21:35 UTC (rev 
4057)
+++ GNUnet/src/applications/dht/tools/dht_api.c 2006-12-27 05:35:16 UTC (rev 
4058)
@@ -19,32 +19,18 @@
  */
 
 /**
- * @file tools/dht_api.c
+ * @file dht/tools/dht_api.c
  * @brief DHT-module's core API's implementation.
  * @author Tomi Tukiainen, Christian Grothoff
  */
 
 #include "platform.h"
 #include "gnunet_protocols.h"
+#include "dht.h"
 #include "gnunet_dht_lib.h"
-#include "gnunet_dht.h"
 #include "gnunet_util_network_client.h"
 
-/**
- * Check if the given message is an ACK.  If so,
- * return the status, otherwise SYSERR.
- */
-static int checkACK(MESSAGE_HEADER * reply) {
-  GE_LOG(NULL,
-        GE_DEBUG | GE_REQUEST | GE_USER,
-        "received ACK from gnunetd\n");
- if ( (sizeof(CS_dht_reply_ack_MESSAGE) == ntohs(reply->size)) &&
-       (CS_PROTO_dht_REPLY_ACK == ntohs(reply->type)) )
-    return ntohl(((CS_dht_reply_ack_MESSAGE*)reply)->status);
-  return SYSERR;
-}
 
-
 /**
  * Perform a synchronous GET operation on the DHT identified by
  * 'table' using 'key' as the key; store the result in 'result'.  If
@@ -66,49 +52,34 @@
  */
 int DHT_LIB_get(struct GC_Configuration * cfg,
                struct GE_Context * ectx,
-               const DHT_TableId * table,
                unsigned int type,
-               unsigned int prio,
-               unsigned int keyCount,
-               const HashCode512 * keys,
+               const HashCode512 * key,
                cron_t timeout,
                DataProcessor processor,
                void * closure) {
   struct ClientServerConnection * sock;
-  CS_dht_request_get_MESSAGE * req;
-  CS_dht_reply_results_MESSAGE * res;
-  MESSAGE_HEADER * reply;
+  CS_dht_request_get_MESSAGE req;
   int ret;
-  unsigned int size;
-  DataContainer * result;
 
   sock = client_connection_create(ectx,
                                  cfg);
   if (sock == NULL)
     return SYSERR;
-
-  req = MALLOC(sizeof(CS_dht_request_get_MESSAGE) +
-              (keyCount-1) * sizeof(HashCode512));
-  req->header.size = htons(sizeof(CS_dht_request_get_MESSAGE) +
-                          (keyCount-1) * sizeof(HashCode512));
-  req->header.type = htons(CS_PROTO_dht_REQUEST_GET);
-  req->type = htonl(type);
-  req->timeout = htonll(timeout);
-  req->table = *table;
-  req->priority = htonl(prio);
-  memcpy(&req->keys,
-        keys,
-        keyCount * sizeof(HashCode512));
+  req.header.size = htons(sizeof(CS_dht_request_get_MESSAGE));
+  req.header.type = htons(CS_PROTO_dht_REQUEST_GET);
+  req.type = htonl(type);
+  req.timeout = htonll(timeout);
+  req.key = *key;
   if (OK != connection_write(sock,
-                            &req->header)) {
+                            &req.header)) {
     connection_destroy(sock);
     return SYSERR;
   }
-  FREE(req);
+#if 0
   while (1) {
     reply = NULL;
     if (OK != connection_read(sock,
-                            &reply)) {
+                             &reply)) {
       connection_destroy(sock);
       return SYSERR;
     }
@@ -145,6 +116,7 @@
              closure);
     FREE(result);
   }
+#endif
   connection_destroy(sock);
   return ret;
 }
@@ -162,14 +134,12 @@
  */
 int DHT_LIB_put(struct GC_Configuration * cfg,
                struct GE_Context * ectx,
-               const DHT_TableId * table,
                const HashCode512 * key,
-               unsigned int prio,
-               cron_t timeout,
+               unsigned int type,
+               cron_t expire,
                const DataContainer * value) {
   struct ClientServerConnection * sock;
   CS_dht_request_put_MESSAGE * req;
-  MESSAGE_HEADER * reply;
   int ret;
 
   GE_LOG(ectx,
@@ -177,15 +147,12 @@
         "DHT_LIB_put called with value '%.*s'\n",
         ntohl(value->size),
         &value[1]);
-
   sock = client_connection_create(ectx,
                                  cfg);
-  if (sock == NULL) {
-    GE_LOG(ectx,
-          GE_DEBUG | GE_REQUEST | GE_USER,
-          "Could not connect to gnunetd\n");
+  if (sock == NULL) 
     return SYSERR;
-  }
+  GE_ASSERT(NULL,
+           ntohl(value->size) >= sizeof(DataContainer));
   req = MALLOC(sizeof(CS_dht_request_put_MESSAGE) +
               ntohl(value->size) -
               sizeof(DataContainer));
@@ -195,23 +162,14 @@
            sizeof(DataContainer));
   req->header.type
     = htons(CS_PROTO_dht_REQUEST_PUT);
-  req->table = *table;
   req->key = *key;
-  req->priority = htonl(prio);
-  req->timeout = htonll(timeout);
+  req->type = htonl(type);
+  req->expire = htonll(expire);
   memcpy(&req[1],
         &value[1],
         ntohl(value->size) - sizeof(DataContainer));
-  ret = SYSERR;
-  if (OK == connection_write(sock,
-                            &req->header))
-    reply = NULL;
-    if (OK == connection_read(sock,
-                            &reply)) {
-      if (OK == checkACK(reply))
-       ret = OK;
-      FREE(reply);
-    }
+  ret = connection_write(sock,
+                        &req->header);
   connection_destroy(sock);
   return ret;
 }

Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c      2006-12-27 05:21:35 UTC (rev 
4057)
+++ GNUnet/src/applications/fs/module/fs.c      2006-12-27 05:35:16 UTC (rev 
4058)
@@ -88,11 +88,6 @@
 
 static int migration;
 
-/**
- * ID of the FS table in the DHT infrastructure.
- */
-static DHT_TableId dht_table;
-
 static struct SEMAPHORE * ltgSignal;
 
 static struct PTHREAD * localGetProcessor;
@@ -1119,9 +1114,6 @@
                                               YES);
   if (migration == SYSERR)
     return SYSERR;
-  hash("GNUNET_FS",
-       strlen("GNUNET_FS"),
-       &dht_table);
   if (GC_get_configuration_value_number(capi->cfg,
                                        "FS",
                                        "QUOTA",

Modified: GNUnet/src/include/Makefile.am
===================================================================
--- GNUnet/src/include/Makefile.am      2006-12-27 05:21:35 UTC (rev 4057)
+++ GNUnet/src/include/Makefile.am      2006-12-27 05:35:16 UTC (rev 4058)
@@ -2,6 +2,7 @@
 
 EXTRA_DIST = \
   core.h \
+  dht.h \
   ecrs_core.h \
   fs.h \
   gettext.h \
@@ -17,7 +18,6 @@
   gnunet_collection_lib.h \
   gnunet_core.h \
   gnunet_datastore_service.h \
-  gnunet_dht.h \
   gnunet_dht_lib.h \
   gnunet_dht_service.h \
   gnunet_directories.h \

Copied: GNUnet/src/include/dht.h (from rev 4057, 
GNUnet/src/include/gnunet_dht.h)

Deleted: GNUnet/src/include/gnunet_dht.h
===================================================================
--- GNUnet/src/include/gnunet_dht.h     2006-12-27 05:21:35 UTC (rev 4057)
+++ GNUnet/src/include/gnunet_dht.h     2006-12-27 05:35:16 UTC (rev 4058)
@@ -1,88 +0,0 @@
-/*
-      This file is part of GNUnet
-      (C) 2004, 2005, 2006 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 include/gnunet_dht.h
- * @brief data structures exchanged between between DHT clients and the GNUnet 
DHT module
- * @author Tomi Tukiainen, Marko R�ih�, Christian Grothoff
- *
- * Typical clients are likely to prefer using the synchronous
- * gnunet_dht_lib instead of sending these messages manually.
- */
-
-#ifndef GNUNET_DHT_H
-#define GNUNET_DHT_H
-
-#include "gnunet_util.h"
-
-#ifdef __cplusplus
-extern "C" {
-#if 0 /* keep Emacsens' auto-indent happy */
-}
-#endif
-#endif
-
-/**
- * TCP communication: put <key,value>-mapping to table.
- * When send by a client to gnunetd, this message is
- * used to initiate a PUT on the DHT.  gnunetd also
- * uses this message to communicate results from a GET
- * operation back to the client.<p>
- *
- * The given struct is followed by the value.
- */
-typedef struct {
-
-  MESSAGE_HEADER header;
-
-  unsigned int type; /* nbo */
-
-  unsigned long long expire;  /* nbo */
-
-  HashCode512 key;
-
-} CS_dht_request_put_MESSAGE;
-
-/**
- * TCP communication: get <key,value>-mappings for given key. Reply is
- * a CS_dht_request_put_MESSAGE messages.  Clients can abort
- * the GET operation early by closing the connection.
- */
-typedef struct {
-
-  MESSAGE_HEADER header;
-
-  unsigned int type; /* nbo */
-
-  unsigned long long timeout;  /* nbo */
-
-  HashCode512 key;
-
-} CS_dht_request_get_MESSAGE;
-
-#if 0 /* keep Emacsens' auto-indent happy */
-{
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* GNUNET_DHT_H */

Modified: GNUnet/src/include/gnunet_dht_lib.h
===================================================================
--- GNUnet/src/include/gnunet_dht_lib.h 2006-12-27 05:21:35 UTC (rev 4057)
+++ GNUnet/src/include/gnunet_dht_lib.h 2006-12-27 05:35:16 UTC (rev 4058)
@@ -38,51 +38,38 @@
 #endif
 
 /**
- * Perform a synchronous GET operation on the DHT identified by
- * 'table' using 'key' as the key; store the result in 'result'.  If
- * result->dataLength == 0 the result size is unlimited and
- * result->data needs to be allocated; otherwise result->data refers
- * to dataLength bytes and the result is to be stored at that
- * location; dataLength is to be set to the actual size of the
- * result.
+ * Perform a synchronous GET operation on the DHT looking for
+ * key.
  *
- * The peer does not have to be part of the table!
- *
- * @param table table to use for the lookup
- * @param keys the keys to look up
+ * @param key the key to look up
  * @param timeout how long to wait until this operation should
  *        automatically time-out
- * @param resultCallback function to call for results
+ * @param resultCallback function to call for results,
+ *        the operation also aborts if the callback returns 
+ *        SYSERR
  * @return number of results on success, SYSERR on error (i.e. timeout)
  */
 int DHT_LIB_get(struct GC_Configuration * cfg,
                struct GE_Context * ectx,
-               const DHT_TableId * table,
                unsigned int type,
-               unsigned int prio,
-               unsigned int keyCount,
-               const HashCode512 * keys,
+               const HashCode512 * key,
                cron_t timeout,
                DataProcessor resultCallback,
                void * resCallbackClosure);
        
 /**
- * Perform a synchronous put operation.   The peer does not have
- * to be part of the table!
+ * Perform a synchronous put operation.
  *
- * @param table table to use for the lookup
  * @param key the key to store
- * @param timeout how long to wait until this operation should
- *        automatically time-out
+ * @param expire when should the content expire
  * @param value what to store
- * @return OK on success, SYSERR on error (or timeout)
+ * @return OK on success, SYSERR on error 
  */
 int DHT_LIB_put(struct GC_Configuration * cfg,
                struct GE_Context * ectx,
-               const DHT_TableId * table,
                const HashCode512 * key,
-               unsigned int prio,
-               cron_t timeout,
+               unsigned int type,
+               cron_t expire,
                const DataContainer * value);
 
 #if 0 /* keep Emacsens' auto-indent happy */

Modified: GNUnet/src/include/gnunet_dht_service.h
===================================================================
--- GNUnet/src/include/gnunet_dht_service.h     2006-12-27 05:21:35 UTC (rev 
4057)
+++ GNUnet/src/include/gnunet_dht_service.h     2006-12-27 05:35:16 UTC (rev 
4058)
@@ -22,7 +22,7 @@
  * @file include/gnunet_dht_service.h
  * @brief API to the DHT-module.  This API is what will be used by
  *     DHT clients that run as modules within gnunetd.  If you
- *     are writing a client look at either gnunet_dht.h (if you
+ *     are writing a client look at either dht.h (if you
  *     want to handle the communication with gnunetd yourself) or
  *     at gnunet_dht_lib to use the convenience library.
  * @author Christian Grothoff
@@ -32,7 +32,6 @@
 #define GNUNET_DHT_SERVICE_H
 
 #include "gnunet_core.h"
-#include "gnunet_dht.h"
 #include "gnunet_blockstore.h"
 
 #ifdef __cplusplus





reply via email to

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