[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r17056 - gnunet/src/dht
From: |
gnunet |
Subject: |
[GNUnet-SVN] r17056 - gnunet/src/dht |
Date: |
Tue, 27 Sep 2011 15:37:30 +0200 |
Author: grothoff
Date: 2011-09-27 15:37:30 +0200 (Tue, 27 Sep 2011)
New Revision: 17056
Modified:
gnunet/src/dht/Makefile.am
gnunet/src/dht/dht_api_new.c
gnunet/src/dht/gnunet-service-dht-new.c
gnunet/src/dht/gnunet-service-dht_clients.c
gnunet/src/dht/gnunet-service-dht_clients.h
gnunet/src/dht/gnunet-service-dht_datacache.c
gnunet/src/dht/gnunet-service-dht_neighbours.c
Log:
getting client API to compile
Modified: gnunet/src/dht/Makefile.am
===================================================================
--- gnunet/src/dht/Makefile.am 2011-09-27 13:30:40 UTC (rev 17055)
+++ gnunet/src/dht/Makefile.am 2011-09-27 13:37:30 UTC (rev 17056)
@@ -18,7 +18,9 @@
XLIB = -lgcov
endif
-lib_LTLIBRARIES = libgnunetdht.la \
+lib_LTLIBRARIES = \
+ libgnunetdht.la \
+ libgnunetdhtnew.la \
libgnunetdhtlog.la
plugin_LTLIBRARIES = \
Modified: gnunet/src/dht/dht_api_new.c
===================================================================
--- gnunet/src/dht/dht_api_new.c 2011-09-27 13:30:40 UTC (rev 17055)
+++ gnunet/src/dht/dht_api_new.c 2011-09-27 13:37:30 UTC (rev 17056)
@@ -26,17 +26,13 @@
*/
#include "platform.h"
-#include "gnunet_bandwidth_lib.h"
-#include "gnunet_client_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
-#include "gnunet_container_lib.h"
#include "gnunet_arm_service.h"
#include "gnunet_hello_lib.h"
#include "gnunet_protocols.h"
-#include "gnunet_server_lib.h"
-#include "gnunet_time_lib.h"
-#include "gnunet_dht_service.h"
-#include "dht.h"
+#include "gnunet_dht_service_new.h"
+#include "dht_new.h"
#define DEBUG_DHT_API GNUNET_NO
@@ -104,9 +100,9 @@
/**
- * Handle to a route request
+ * Handle to a GET request
*/
-struct GNUNET_DHT_RouteHandle
+struct GNUNET_DHT_GetHandle
{
/**
@@ -242,14 +238,14 @@
*
* @param cls the 'struct GNUNET_DHT_Handle*'
* @param key key for the request (not used)
- * @param value the 'struct GNUNET_DHT_RouteHandle*'
+ * @param value the 'struct GNUNET_DHT_GetHandle*'
* @return GNUNET_YES (always)
*/
static int
add_request_to_pending (void *cls, const GNUNET_HashCode * key, void *value)
{
struct GNUNET_DHT_Handle *handle = cls;
- struct GNUNET_DHT_RouteHandle *rh = value;
+ struct GNUNET_DHT_GetHandle *rh = value;
if (GNUNET_NO == rh->message->in_pending_queue)
{
@@ -424,7 +420,7 @@
process_reply (void *cls, const GNUNET_HashCode * key, void *value)
{
const struct GNUNET_DHT_ClientResultMessage *dht_msg = cls;
- struct GNUNET_DHT_RouteHandle *rh = value;
+ struct GNUNET_DHT_GetHandle *rh = value;
const struct GNUNET_PeerIdentity *put_path;
const struct GNUNET_PeerIdentity *get_path;
uint32_t put_path_length;
@@ -440,10 +436,10 @@
return GNUNET_YES;
}
msize = ntohs (dht_msg->header.size);
+ put_path_length = ntohl (dht_msg->put_path_length);
+ get_path_length = ntohl (dht_msg->get_path_length);
meta_length = sizeof (struct GNUNET_DHT_ClientResultMessage) +
sizeof (struct GNUNET_PeerIdentity) * (get_path_length + put_path_length);
- put_path_length = ntohl (dht_msg->put_path_length);
- get_path_length = ntohl (dht_msg->get_path_length);
if ( (msize < meta_length) ||
(get_path_length > GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct
GNUNET_PeerIdentity)) ||
(put_path_length > GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct
GNUNET_PeerIdentity)) )
@@ -461,7 +457,7 @@
get_path, get_path_length,
put_path, put_path_length,
ntohl (dht_msg->type),
- data_size, data);
+ data_length, data);
return GNUNET_YES;
}
@@ -477,7 +473,7 @@
service_message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
{
struct GNUNET_DHT_Handle *handle = cls;
- const struct GNUNET_DHT_RouteResultMessage *dht_msg;
+ const struct GNUNET_DHT_ClientResultMessage *dht_msg;
if (msg == NULL)
{
@@ -492,13 +488,13 @@
do_disconnect (handle);
return;
}
- if (ntohs (msg->size) < sizeof (struct GNUNET_DHT_RouteResultMessage))
+ if (ntohs (msg->size) < sizeof (struct GNUNET_DHT_ClientResultMessage))
{
GNUNET_break (0);
do_disconnect (handle);
return;
}
- dht_msg = (const struct GNUNET_DHT_RouteResultMessage *) msg;
+ dht_msg = (const struct GNUNET_DHT_ClientResultMessage *) msg;
GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_requests,
&dht_msg->key, &process_reply,
(void *) dht_msg);
@@ -626,9 +622,12 @@
void *cont_cls)
{
struct GNUNET_DHT_ClientPutMessage *put_msg;
+ size_t msize;
+ struct PendingMessage *pending;
msize = sizeof (struct GNUNET_DHT_ClientPutMessage) + size;
- if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if ( (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
+ (size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) )
{
GNUNET_break (0);
if (NULL != cont)
@@ -636,24 +635,22 @@
return;
}
pending = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
- message = (struct GNUNET_DHT_ClientPutMessage *) &pending[1];
- pending->msg = &message->header;
+ put_msg = (struct GNUNET_DHT_ClientPutMessage *) &pending[1];
+ pending->msg = &put_msg->header;
pending->handle = handle;
pending->cont = cont;
pending->cont_cls = cont_cls;
pending->free_on_send = GNUNET_YES;
pending->timeout_task =
GNUNET_SCHEDULER_add_delayed (timeout, &timeout_put_request, pending);
- message->header.size = htons (msize);
- message->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT);
- message->type = htonl (type);
- message->options = htonl ((uint32_t) options);
- message->desired_replication_level = htonl (desired_replication_level);
- message->expiration = GNUNET_TIME_absolute_hton (exp);
- message->key = *key;
- handle->uid_gen++;
- message->unique_id = handle->uid_gen;
- memcpy (&message[1], data, size);
+ put_msg->header.size = htons (msize);
+ put_msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT);
+ put_msg->type = htonl (type);
+ put_msg->options = htonl ((uint32_t) options);
+ put_msg->desired_replication_level = htonl (desired_replication_level);
+ put_msg->expiration = GNUNET_TIME_absolute_hton (exp);
+ put_msg->key = *key;
+ memcpy (&put_msg[1], data, size);
GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail,
pending);
pending->in_pending_queue = GNUNET_YES;
@@ -689,37 +686,40 @@
{
struct GNUNET_DHT_ClientGetMessage *get_msg;
struct GNUNET_DHT_GetHandle *get_handle;
+ size_t msize;
+ struct PendingMessage *pending;
msize = sizeof (struct GNUNET_DHT_ClientGetMessage) + xquery_size;
- if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ if ( (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
+ (xquery_size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) )
{
GNUNET_break (0);
return NULL;
}
pending = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
- message = (struct GNUNET_DHT_ClientGetMessage *) &pending[1];
- pending->msg = &message->header;
+ get_msg = (struct GNUNET_DHT_ClientGetMessage *) &pending[1];
+ pending->msg = &get_msg->header;
pending->handle = handle;
pending->free_on_send = GNUNET_NO;
- message->header.size = htons (msize);
- message->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET);
- message->options = htonl ((uint32_t) options);
- message->desired_replication_level = htonl (desired_replication_level);
- message->type = htonl (type);
- message->key = *key;
+ get_msg->header.size = htons (msize);
+ get_msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET);
+ get_msg->options = htonl ((uint32_t) options);
+ get_msg->desired_replication_level = htonl (desired_replication_level);
+ get_msg->type = htonl (type);
+ get_msg->key = *key;
handle->uid_gen++;
- message->unique_id = handle->uid_gen;
- memcpy (&message[1], xquery, xquery_size);
+ get_msg->unique_id = handle->uid_gen;
+ memcpy (&get_msg[1], xquery, xquery_size);
GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail,
pending);
pending->in_pending_queue = GNUNET_YES;
get_handle = GNUNET_malloc (sizeof (struct GNUNET_DHT_GetHandle));
get_handle->iter = iter;
get_handle->iter_cls = iter_cls;
- get_handle->route_handle = pending;
+ get_handle->message = pending;
GNUNET_CONTAINER_multihashmap_put (handle->active_requests,
key, get_handle,
-
GNUNET_CONTAINER_MULITHASHMAPOPTION_MULTIPLE);
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
process_pending_messages (handle);
return get_handle;
}
@@ -736,19 +736,20 @@
struct GNUNET_DHT_Handle *handle;
const struct GNUNET_DHT_ClientGetMessage *get_msg;
- handle = get_handle->pending->handle;
- get_msg = (const struct GNUNET_DHT_ClientGetMessage*)
get_handle->pending->msg;
+ /* FIXME: send STOP to service! */
+ handle = get_handle->message->handle;
+ get_msg = (const struct GNUNET_DHT_ClientGetMessage*)
get_handle->message->msg;
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (handle->active_requests,
&get_msg->key,
get_handle));
- if (GNUNET_YES == get_handle->pending->in_pending_queue)
+ if (GNUNET_YES == get_handle->message->in_pending_queue)
{
GNUNET_CONTAINER_DLL_remove (handle->pending_head,
handle->pending_tail,
- get_handle->pending);
- get_handle->pending->in_pending_queue = GNUNET_NO;
+ get_handle->message);
+ get_handle->message->in_pending_queue = GNUNET_NO;
}
- GNUNET_free (get_handle->pending);
+ GNUNET_free (get_handle->message);
GNUNET_free (get_handle);
}
Modified: gnunet/src/dht/gnunet-service-dht-new.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht-new.c 2011-09-27 13:30:40 UTC (rev
17055)
+++ gnunet/src/dht/gnunet-service-dht-new.c 2011-09-27 13:37:30 UTC (rev
17056)
@@ -113,7 +113,7 @@
GDS_NEIGHBOURS_done ();
GDS_DATACACHE_done ();
GDS_ROUTING_done ();
- GDS_CLIENT_done ();
+ GDS_CLIENTS_done ();
GDS_NSE_done ();
if (GDS_block_context != NULL)
{
@@ -147,7 +147,7 @@
GDS_ROUTING_init ();
GDS_NSE_init ();
GDS_DATACACHE_init ();
- GDS_CLIENT_init (server);
+ GDS_CLIENTS_init (server);
if (GNUNET_OK !=
GDS_NEIGHBOURS_init ())
{
Modified: gnunet/src/dht/gnunet-service-dht_clients.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_clients.c 2011-09-27 13:30:40 UTC (rev
17055)
+++ gnunet/src/dht/gnunet-service-dht_clients.c 2011-09-27 13:37:30 UTC (rev
17056)
@@ -386,7 +386,7 @@
}
dht_msg = (const struct GNUNET_DHT_ClientPutMessage *) message;
/* give to local clients */
- GDS_CLIENT_handle_reply (GNUNET_TIME_absolute_ntoh (dht_msg->expiration),
+ GDS_CLIENTS_handle_reply (GNUNET_TIME_absolute_ntoh (dht_msg->expiration),
&dht_msg->key,
0, NULL,
0, NULL,
@@ -772,7 +772,7 @@
* @param data application payload data
*/
void
-GDS_CLIENT_handle_reply (struct GNUNET_TIME_Absolute expiration,
+GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
const GNUNET_HashCode *key,
unsigned int get_path_length,
const struct GNUNET_PeerIdentity *get_path,
@@ -840,7 +840,7 @@
* @param server the initialized server
*/
void
-GDS_CLIENT_init (struct GNUNET_SERVER_Handle *server)
+GDS_CLIENTS_init (struct GNUNET_SERVER_Handle *server)
{
static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = {
{&handle_dht_local_put, NULL,
@@ -863,7 +863,7 @@
* Shutdown client subsystem.
*/
void
-GDS_CLIENT_done ()
+GDS_CLIENTS_done ()
{
GNUNET_assert (client_head == NULL);
GNUNET_assert (client_tail == NULL);
Modified: gnunet/src/dht/gnunet-service-dht_clients.h
===================================================================
--- gnunet/src/dht/gnunet-service-dht_clients.h 2011-09-27 13:30:40 UTC (rev
17055)
+++ gnunet/src/dht/gnunet-service-dht_clients.h 2011-09-27 13:37:30 UTC (rev
17056)
@@ -24,8 +24,8 @@
* @author Christian Grothoff
* @author Nathan Evans
*/
-#ifndef GNUNET_SERVICE_DHT_CLIENTS_H
-#define GNUNET_SERVICE_DHT_CLIENTS_H
+#ifndef GNUNET_SERVICE_DHT_CLIENT_H
+#define GNUNET_SERVICE_DHT_CLIENT_H
#include "gnunet_util_lib.h"
#include "gnunet_block_lib.h"
@@ -46,7 +46,7 @@
* @param data application payload data
*/
void
-GDS_CLIENT_handle_reply (struct GNUNET_TIME_Absolute expiration,
+GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
const GNUNET_HashCode *key,
unsigned int get_path_length,
const struct GNUNET_PeerIdentity *get_path,
@@ -63,13 +63,13 @@
* @param server the initialized server
*/
void
-GDS_CLIENT_init (struct GNUNET_SERVER_Handle *server);
+GDS_CLIENTS_init (struct GNUNET_SERVER_Handle *server);
/**
* Shutdown client subsystem.
*/
void
-GDS_CLIENT_done (void);
+GDS_CLIENTS_done (void);
#endif
Modified: gnunet/src/dht/gnunet-service-dht_datacache.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_datacache.c 2011-09-27 13:30:40 UTC
(rev 17055)
+++ gnunet/src/dht/gnunet-service-dht_datacache.c 2011-09-27 13:37:30 UTC
(rev 17056)
@@ -202,7 +202,7 @@
case GNUNET_BLOCK_EVALUATION_OK_LAST:
case GNUNET_BLOCK_EVALUATION_OK_MORE:
/* forward to local clients */
- GDS_CLIENT_handle_reply (exp,
+ GDS_CLIENTS_handle_reply (exp,
key,
0, NULL,
put_path_length, pp,
Modified: gnunet/src/dht/gnunet-service-dht_neighbours.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_neighbours.c 2011-09-27 13:30:40 UTC
(rev 17055)
+++ gnunet/src/dht/gnunet-service-dht_neighbours.c 2011-09-27 13:37:30 UTC
(rev 17056)
@@ -1478,7 +1478,7 @@
putlen = 0;
/* give to local clients */
- GDS_CLIENT_handle_reply (GNUNET_TIME_absolute_ntoh (put->expiration_time),
+ GDS_CLIENTS_handle_reply (GNUNET_TIME_absolute_ntoh (put->expiration_time),
&put->key,
0, NULL,
putlen,
@@ -1806,7 +1806,7 @@
get_path_length++;
/* forward to local clients */
- GDS_CLIENT_handle_reply (GNUNET_TIME_absolute_ntoh (prm->expiration_time),
+ GDS_CLIENTS_handle_reply (GNUNET_TIME_absolute_ntoh (prm->expiration_time),
&prm->key,
get_path_length,
xget_path,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r17056 - gnunet/src/dht,
gnunet <=