[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32819 - in gnunet/src: dht include
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32819 - in gnunet/src: dht include |
Date: |
Fri, 28 Mar 2014 11:24:39 +0100 |
Author: supriti
Date: 2014-03-28 11:24:39 +0100 (Fri, 28 Mar 2014)
New Revision: 32819
Modified:
gnunet/src/dht/gnunet-service-dht_neighbours.c
gnunet/src/dht/gnunet-service-xdht_clients.c
gnunet/src/dht/gnunet-service-xdht_clients.h
gnunet/src/dht/gnunet-service-xdht_datacache.c
gnunet/src/dht/gnunet-service-xdht_neighbours.c
gnunet/src/dht/gnunet-service-xdht_neighbours.h
gnunet/src/dht/gnunet-service-xdht_routing.c
gnunet/src/include/gnunet_protocols.h
Log:
Framework for put/get/monitor
Modified: gnunet/src/dht/gnunet-service-dht_neighbours.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_neighbours.c 2014-03-28 08:41:34 UTC
(rev 32818)
+++ gnunet/src/dht/gnunet-service-dht_neighbours.c 2014-03-28 10:24:39 UTC
(rev 32819)
@@ -1601,8 +1601,7 @@
* #GNUNET_SYSERR to close it (signal serious error)
*/
static int
-handle_dht_p2p_put (void *cls,
- const struct GNUNET_PeerIdentity *peer,
+handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
const struct PeerPutMessage *put;
@@ -1645,6 +1644,7 @@
payload_size =
msize - (sizeof (struct PeerPutMessage) +
putlen * sizeof (struct GNUNET_PeerIdentity));
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PUT for `%s' from %s\n",
GNUNET_h2s (&put->key), GNUNET_i2s (peer));
GNUNET_CRYPTO_hash (peer, sizeof (struct GNUNET_PeerIdentity), &phash);
Modified: gnunet/src/dht/gnunet-service-xdht_clients.c
===================================================================
--- gnunet/src/dht/gnunet-service-xdht_clients.c 2014-03-28 08:41:34 UTC
(rev 32818)
+++ gnunet/src/dht/gnunet-service-xdht_clients.c 2014-03-28 10:24:39 UTC
(rev 32819)
@@ -19,10 +19,9 @@
*/
/**
- * @file dht/gnunet-service-xdht_clients.c
+ * @file dht/gnunet-service-dht_clients.c
* @brief GNUnet DHT service's client management code
- * @author Christian Grothoff
- * @author Nathan Evans
+ * @author Supriti Singh
*/
#include "platform.h"
@@ -35,15 +34,7 @@
#include "gnunet-service-xdht_neighbours.h"
#include "dht.h"
-
/**
- * Should routing details be logged to stderr (for debugging)?
- */
-#define LOG_TRAFFIC(kind,...) GNUNET_log_from (kind, "dht-traffic",__VA_ARGS__)
-
-#define LOG(kind,...) GNUNET_log_from (kind, "dht-clients",__VA_ARGS__)
-
-/**
* Linked list of messages to send to clients.
*/
struct PendingMessage
@@ -67,7 +58,6 @@
};
-
/**
* Struct containing information about a client,
* handle to connect to it, and any pending messages
@@ -110,129 +100,6 @@
/**
- * Entry in the DHT routing table for a client's GET request.
- */
-struct ClientQueryRecord
-{
-
- /**
- * The key this request was about
- */
- struct GNUNET_HashCode key;
-
- /**
- * Client responsible for the request.
- */
- struct ClientList *client;
-
- /**
- * Extended query (see gnunet_block_lib.h), allocated at the end of this
struct.
- */
- const void *xquery;
-
- /**
- * Replies we have already seen for this request.
- */
- struct GNUNET_HashCode *seen_replies;
-
- /**
- * Pointer to this nodes heap location in the retry-heap (for fast removal)
- */
- struct GNUNET_CONTAINER_HeapNode *hnode;
-
- /**
- * What's the delay between re-try operations that we currently use for this
- * request?
- */
- struct GNUNET_TIME_Relative retry_frequency;
-
- /**
- * What's the next time we should re-try this request?
- */
- struct GNUNET_TIME_Absolute retry_time;
-
- /**
- * The unique identifier of this request
- */
- uint64_t unique_id;
-
- /**
- * Number of bytes in xquery.
- */
- size_t xquery_size;
-
- /**
- * Number of entries in 'seen_replies'.
- */
- unsigned int seen_replies_count;
-
- /**
- * Desired replication level
- */
- uint32_t replication;
-
- /**
- * Any message options for this request
- */
- uint32_t msg_options;
-
- /**
- * The type for the data for the GET request.
- */
- enum GNUNET_BLOCK_Type type;
-
-};
-
-
-/**
- * Struct containing paremeters of monitoring requests.
- */
-struct ClientMonitorRecord
-{
-
- /**
- * Next element in DLL.
- */
- struct ClientMonitorRecord *next;
-
- /**
- * Previous element in DLL.
- */
- struct ClientMonitorRecord *prev;
-
- /**
- * Type of blocks that are of interest
- */
- enum GNUNET_BLOCK_Type type;
-
- /**
- * Key of data of interest, NULL for all.
- */
- struct GNUNET_HashCode *key;
-
- /**
- * Flag whether to notify about GET messages.
- */
- int16_t get;
-
- /**
- * Flag whether to notify about GET_REPONSE messages.
- */
- int16_t get_resp;
-
- /**
- * Flag whether to notify about PUT messages.
- */
- uint16_t put;
-
- /**
- * Client to notify of these requests.
- */
- struct ClientList *client;
-};
-
-
-/**
* List of active clients.
*/
static struct ClientList *client_head;
@@ -243,38 +110,87 @@
static struct ClientList *client_tail;
/**
- * List of active monitoring requests.
+ * Task run to check for messages that need to be sent to a client.
+ *
+ * @param client a ClientList, containing the client and any messages to be
sent to it
*/
-static struct ClientMonitorRecord *monitor_head;
-
+static void process_pending_messages (struct ClientList *client);
/**
- * List of active monitoring requests.
+ * Callback called as a result of issuing a GNUNET_SERVER_notify_transmit_ready
+ * request. A ClientList is passed as closure, take the head of the list
+ * and copy it into buf, which has the result of sending the message to the
+ * client.
+ *
+ * @param cls closure to this call
+ * @param size maximum number of bytes available to send
+ * @param buf where to copy the actual message to
+ *
+ * @return the number of bytes actually copied, 0 indicates failure
*/
-static struct ClientMonitorRecord *monitor_tail;
+static size_t
+send_reply_to_client (void *cls, size_t size, void *buf)
+{
+ struct ClientList *client = cls;
+ char *cbuf = buf;
+ struct PendingMessage *reply;
+ size_t off;
+ size_t msize;
-/**
- * Hashmap for fast key based lookup, maps keys to 'struct ClientQueryRecord'
entries.
- */
-static struct GNUNET_CONTAINER_MultiHashMap *forward_map;
+ client->transmit_handle = NULL;
+ if (buf == NULL)
+ {
+ /* client disconnected */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client %p disconnected, pending messages will be discarded\n",
+ client->client_handle);
+ return 0;
+ }
+ off = 0;
+ while ((NULL != (reply = client->pending_head)) &&
+ (size >= off + (msize = ntohs (reply->msg->size))))
+ {
+ GNUNET_CONTAINER_DLL_remove (client->pending_head, client->pending_tail,
+ reply);
+ memcpy (&cbuf[off], reply->msg, msize);
+ GNUNET_free (reply);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting %u bytes to client
%p\n",
+ msize, client->client_handle);
+ off += msize;
+ }
+ process_pending_messages (client);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitted %u/%u bytes to client
%p\n",
+ (unsigned int) off, (unsigned int) size, client->client_handle);
+ return off;
+}
-/**
- * Heap with all of our client's request, sorted by retry time (earliest on
top).
- */
-static struct GNUNET_CONTAINER_Heap *retry_heap;
/**
- * Task that re-transmits requests (using retry_heap).
- */
-static GNUNET_SCHEDULER_TaskIdentifier retry_task;
-
-
-/**
* Task run to check for messages that need to be sent to a client.
*
* @param client a ClientList, containing the client and any messages to be
sent to it
*/
static void
-process_pending_messages (struct ClientList *client);
+process_pending_messages (struct ClientList *client)
+{
+ if ((client->pending_head == NULL) || (client->transmit_handle != NULL))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Not asking for transmission to %p now: %s\n",
+ client->client_handle,
+ client->pending_head ==
+ NULL ? "no more messages" : "request already pending");
+ return;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Asking for transmission of %u bytes to client %p\n",
+ ntohs (client->pending_head->msg->size), client->client_handle);
+ client->transmit_handle =
+ GNUNET_SERVER_notify_transmit_ready (client->client_handle,
+ ntohs (client->pending_head->
+ msg->size),
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &send_reply_to_client, client);
+}
/**
@@ -292,7 +208,6 @@
process_pending_messages (client);
}
-
/**
* Find a client if it exists, add it otherwise.
*
@@ -320,253 +235,67 @@
/**
- * Iterator over hash map entries that frees all entries
- * associated with the given client.
+ * SUPU: Call made from dht_api.c
+ * Handler for monitor stop messages
*
- * @param cls client to search for in source routes
- * @param key current key code (ignored)
- * @param value value in the hash map, a ClientQueryRecord
- * @return #GNUNET_YES (we should continue to iterate)
- */
-static int
-remove_client_records (void *cls, const struct GNUNET_HashCode * key, void
*value)
-{
- struct ClientList *client = cls;
- struct ClientQueryRecord *record = value;
-
- if (record->client != client)
- return GNUNET_YES;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Removing client %p's record for key %s\n", client,
- GNUNET_h2s (key));
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (forward_map, key,
- record));
- if (NULL != record->hnode)
- GNUNET_CONTAINER_heap_remove_node (record->hnode);
- GNUNET_array_grow (record->seen_replies, record->seen_replies_count, 0);
- GNUNET_free (record);
- return GNUNET_YES;
-}
-
-
-/**
- * Functions with this signature are called whenever a client
- * is disconnected on the network level.
+ * @param cls closure for the service
+ * @param client the client we received this message from
+ * @param message the actual message received
*
- * @param cls closure (NULL for dht)
- * @param client identification of the client; NULL
- * for the last call when the server is destroyed
*/
static void
-handle_client_disconnect (void *cls,
- struct GNUNET_SERVER_Client *client)
+handle_dht_local_monitor_stop (void *cls, struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
{
-
- struct ClientList *pos;
- struct PendingMessage *reply;
- struct ClientMonitorRecord *monitor;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Local client %p disconnects\n",
- client);
- pos = find_active_client (client);
- GNUNET_CONTAINER_DLL_remove (client_head, client_tail, pos);
- if (pos->transmit_handle != NULL)
- GNUNET_SERVER_notify_transmit_ready_cancel (pos->transmit_handle);
- while (NULL != (reply = pos->pending_head))
- {
- GNUNET_CONTAINER_DLL_remove (pos->pending_head, pos->pending_tail, reply);
- GNUNET_free (reply);
- }
- monitor = monitor_head;
- while (NULL != monitor)
- {
- if (monitor->client == pos)
- {
- struct ClientMonitorRecord *next;
-
- GNUNET_free_non_null (monitor->key);
- next = monitor->next;
- GNUNET_CONTAINER_DLL_remove (monitor_head, monitor_tail, monitor);
- GNUNET_free (monitor);
- monitor = next;
- }
- else
- monitor = monitor->next;
- }
- GNUNET_CONTAINER_multihashmap_iterate (forward_map, &remove_client_records,
- pos);
- GNUNET_free (pos);
+ //const struct GNUNET_DHT_MonitorStartStopMessage *msg;
}
/**
- * Route the given request via the DHT. This includes updating
- * the bloom filter and retransmission times, building the P2P
- * message and initiating the routing operation.
- */
-static void
-transmit_request (struct ClientQueryRecord *cqr)
-{
- int32_t reply_bf_mutator;
- struct GNUNET_CONTAINER_BloomFilter *reply_bf;
- struct GNUNET_CONTAINER_BloomFilter *peer_bf;
-
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop
- ("# GET requests from clients injected"), 1,
- GNUNET_NO);
- reply_bf_mutator =
- (int32_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- UINT32_MAX);
- reply_bf =
- GNUNET_BLOCK_construct_bloomfilter (reply_bf_mutator, cqr->seen_replies,
- cqr->seen_replies_count);
- peer_bf =
- GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE,
- GNUNET_CONSTANTS_BLOOMFILTER_K);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Initiating GET for %s, replication %u, already have %u replies\n",
- GNUNET_h2s(&cqr->key), cqr->replication, cqr->seen_replies_count);
-
- GDS_NEIGHBOURS_handle_get (cqr->type, cqr->msg_options, cqr->replication,
- 0 /* hop count */ ,
- &cqr->key, cqr->xquery, cqr->xquery_size,
reply_bf,
- reply_bf_mutator, peer_bf);
- GNUNET_CONTAINER_bloomfilter_free (reply_bf);
- GNUNET_CONTAINER_bloomfilter_free (peer_bf);
-
- /* exponential back-off for retries.
- * max GNUNET_TIME_STD_EXPONENTIAL_BACKOFF_THRESHOLD (15 min) */
- cqr->retry_frequency = GNUNET_TIME_STD_BACKOFF (cqr->retry_frequency);
- cqr->retry_time = GNUNET_TIME_relative_to_absolute (cqr->retry_frequency);
-}
-
-
-/**
- * Task that looks at the 'retry_heap' and transmits all of the requests
- * on the heap that are ready for transmission. Then re-schedules
- * itself (unless the heap is empty).
+ * SUPU: Monitor call made from dht_api.c
+ * Handler for monitor start messages
*
- * @param cls unused
- * @param tc scheduler context
+ * @param cls closure for the service
+ * @param client the client we received this message from
+ * @param message the actual message received
+ *
*/
static void
-transmit_next_request_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+handle_dht_local_monitor (void *cls, struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
{
- struct ClientQueryRecord *cqr;
- struct GNUNET_TIME_Relative delay;
-
- retry_task = GNUNET_SCHEDULER_NO_TASK;
- if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
- return;
- while (NULL != (cqr = GNUNET_CONTAINER_heap_remove_root (retry_heap)))
- {
- cqr->hnode = NULL;
- delay = GNUNET_TIME_absolute_get_remaining (cqr->retry_time);
- if (delay.rel_value_us > 0)
- {
- cqr->hnode =
- GNUNET_CONTAINER_heap_insert (retry_heap, cqr,
- cqr->retry_time.abs_value_us);
- retry_task =
- GNUNET_SCHEDULER_add_delayed (delay, &transmit_next_request_task,
- NULL);
- return;
- }
- transmit_request (cqr);
- cqr->hnode =
- GNUNET_CONTAINER_heap_insert (retry_heap, cqr,
- cqr->retry_time.abs_value_us);
- }
+ //const struct GNUNET_DHT_MonitorStartStopMessage *msg;
+ /* FIXME: At the moment I don't know exact usage of monitor message. But most
+ probably it will be just copy and paste from old implementation. */
}
-/**
- * Handler for PUT messages.
+/**SUPU: Call to this function is made whenever a client does not want the
+ * get request any more. There is a function in dht_api.c but I don't know
+ * yet how the call is made to this function.
+ * Handler for any generic DHT stop messages, calls the appropriate handler
+ * depending on message type (if processed locally)
*
* @param cls closure for the service
* @param client the client we received this message from
* @param message the actual message received
+ *
*/
static void
-handle_dht_local_put (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+handle_dht_local_get_stop (void *cls, struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
{
- const struct GNUNET_DHT_ClientPutMessage *dht_msg;
- struct GNUNET_CONTAINER_BloomFilter *peer_bf;
- uint16_t size;
- struct PendingMessage *pm;
- struct GNUNET_DHT_ClientPutConfirmationMessage *conf;
-
- size = ntohs (message->size);
- if (size < sizeof (struct GNUNET_DHT_ClientPutMessage))
- {
- GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
- }
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop
- ("# PUT requests received from clients"), 1,
- GNUNET_NO);
- dht_msg = (const struct GNUNET_DHT_ClientPutMessage *) message;
- LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, "XDHT CLIENT-PUT %s @ %u\n",
- GNUNET_h2s (&dht_msg->key), getpid ());
- /* give to local clients */
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Handling local PUT of %u-bytes for query %s\n",
- size - sizeof (struct GNUNET_DHT_ClientPutMessage),
- GNUNET_h2s (&dht_msg->key));
- GDS_CLIENTS_handle_reply (GNUNET_TIME_absolute_ntoh (dht_msg->expiration),
- &dht_msg->key, 0, NULL, 0, NULL,
- ntohl (dht_msg->type),
- size - sizeof (struct GNUNET_DHT_ClientPutMessage),
- &dht_msg[1]);
- /* store locally */
- GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (dht_msg->expiration),
- &dht_msg->key, 0, NULL, ntohl (dht_msg->type),
- size - sizeof (struct GNUNET_DHT_ClientPutMessage),
- &dht_msg[1]);
- /* route to other peers */
- peer_bf =
- GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE,
- GNUNET_CONSTANTS_BLOOMFILTER_K);
-
- GDS_NEIGHBOURS_handle_put (ntohl (dht_msg->type), ntohl (dht_msg->options),
- ntohl (dht_msg->desired_replication_level),
- GNUNET_TIME_absolute_ntoh (dht_msg->expiration),
- 0 /* hop count */ ,
- peer_bf, &dht_msg->key, 0, NULL, &dht_msg[1],
- size -
- sizeof (struct GNUNET_DHT_ClientPutMessage));
- GDS_CLIENTS_process_put (ntohl (dht_msg->options),
- ntohl (dht_msg->type),
- 0,
- ntohl (dht_msg->desired_replication_level),
- 1,
- GDS_NEIGHBOURS_get_id(),
- GNUNET_TIME_absolute_ntoh (dht_msg->expiration),
- &dht_msg->key,
- &dht_msg[1],
- size - sizeof (struct GNUNET_DHT_ClientPutMessage));
- GNUNET_CONTAINER_bloomfilter_free (peer_bf);
- pm = GNUNET_malloc (sizeof (struct PendingMessage) +
- sizeof (struct GNUNET_DHT_ClientPutConfirmationMessage));
- conf = (struct GNUNET_DHT_ClientPutConfirmationMessage *) &pm[1];
- conf->header.size = htons (sizeof (struct
GNUNET_DHT_ClientPutConfirmationMessage));
- conf->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT_OK);
- conf->reserved = htonl (0);
- conf->unique_id = dht_msg->unique_id;
- pm->msg = &conf->header;
- add_pending_message (find_active_client (client), pm);
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ //const struct GNUNET_DHT_ClientGetStopMessage *dht_stop_msg;
+ /* FIXME: Whats the use of get_stop. A client notifies the server to stop
asking
+ for the get message. But in case of x-vine, it asks for get only once. So,
+ when it has already send the get message, after that if client asks it to
+ stop, it really can't do anything. Its better to wait for the result,
discard
+ it and don't communicate with client about the result instead of generating
+ more traffic.*/
}
-
/**
+ * FIXME: Call to this function is made whenever we have a get request.
* Handler for DHT GET messages from the client.
*
* @param cls closure for the service
@@ -577,12 +306,12 @@
handle_dht_local_get (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
- const struct GNUNET_DHT_ClientGetMessage *get;
- struct ClientQueryRecord *cqr;
- size_t xquery_size;
- const char *xquery;
+ struct GNUNET_DHT_ClientGetMessage *get_msg;
+ struct GNUNET_PeerIdentity *get_path;
+ struct GNUNET_PeerIdentity *my_identity;
+ unsigned int get_path_length;
uint16_t size;
-
+
size = ntohs (message->size);
if (size < sizeof (struct GNUNET_DHT_ClientGetMessage))
{
@@ -590,871 +319,122 @@
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- xquery_size = size - sizeof (struct GNUNET_DHT_ClientGetMessage);
- get = (const struct GNUNET_DHT_ClientGetMessage *) message;
- xquery = (const char *) &get[1];
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop
- ("# GET requests received from clients"), 1,
- GNUNET_NO);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received GET request for %s from local client %p, xq: %.*s\n",
- GNUNET_h2s (&get->key), client, xquery_size, xquery);
-
- LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, "XDHT CLIENT-GET %s @ %u\n",
- GNUNET_h2s (&get->key), getpid ());
-
-
- cqr = GNUNET_malloc (sizeof (struct ClientQueryRecord) + xquery_size);
- cqr->key = get->key;
- cqr->client = find_active_client (client);
- cqr->xquery = (void *) &cqr[1];
- memcpy (&cqr[1], xquery, xquery_size);
- cqr->hnode = GNUNET_CONTAINER_heap_insert (retry_heap, cqr, 0);
- cqr->retry_frequency = GNUNET_TIME_UNIT_SECONDS;
- cqr->retry_time = GNUNET_TIME_absolute_get ();
- cqr->unique_id = get->unique_id;
- cqr->xquery_size = xquery_size;
- cqr->replication = ntohl (get->desired_replication_level);
- cqr->msg_options = ntohl (get->options);
- cqr->type = ntohl (get->type);
- // FIXME use cqr->key, set multihashmap create to GNUNET_YES
- GNUNET_CONTAINER_multihashmap_put (forward_map, &get->key, cqr,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
- GDS_CLIENTS_process_get (ntohl (get->options),
- ntohl (get->type),
- 0,
- ntohl (get->desired_replication_level),
- 1,
- GDS_NEIGHBOURS_get_id(),
- &get->key);
- /* start remote requests */
- if (GNUNET_SCHEDULER_NO_TASK != retry_task)
- GNUNET_SCHEDULER_cancel (retry_task);
- retry_task = GNUNET_SCHEDULER_add_now (&transmit_next_request_task, NULL);
- /* perform local lookup */
- GDS_DATACACHE_handle_get (&get->key, cqr->type, cqr->xquery, xquery_size,
- NULL, 0);
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
+
+ get_msg = (struct GNUNET_DHT_ClientGetMessage *) message;
+
+ /* FIXME: Search locally? Why should we always search locally?
+ Current implementation of datacache needs to be modified. If found here,
then
+ notify the requesting client. */
+
+ /* FIXME: Call GDS_NEIGHBOURS_handle_get
+ Here you need to remember the whole path because you need to travel that
path
+ and reach back here with the result. So, you should send your own id, client
+ id, get path, get path length. You also need to add yourself to the get
path. */
+ my_identity = GDS_NEIGHBOURS_get_id();
+ get_path = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
+ memcpy (get_path, &my_identity, sizeof (struct GNUNET_PeerIdentity));
+ get_path_length = 1;
+
+ /* FIXME:
+ * 1. Find some unique identifier for the client.
+ * 2. Also, I don't know the usage of block, replication and type. So, I
+ * am not sending the parameters now. */
+ GDS_NEIGHBOURS_handle_get (my_identity, get_path, get_path_length,
+ &(get_msg->key), NULL, NULL, NULL);
+
}
/**
- * Closure for 'find_by_unique_id'.
- */
-struct FindByUniqueIdContext
-{
- /**
- * Where to store the result, if found.
- */
- struct ClientQueryRecord *cqr;
-
- uint64_t unique_id;
-};
-
-
-/**
- * Function called for each existing DHT record for the given
- * query. Checks if it matches the UID given in the closure
- * and if so returns the entry as a result.
- *
- * @param cls the search context
- * @param key query for the lookup (not used)
- * @param value the 'struct ClientQueryRecord'
- * @return GNUNET_YES to continue iteration (result not yet found)
- */
-static int
-find_by_unique_id (void *cls,
- const struct GNUNET_HashCode *key,
- void *value)
-{
- struct FindByUniqueIdContext *fui_ctx = cls;
- struct ClientQueryRecord *cqr = value;
-
- if (cqr->unique_id != fui_ctx->unique_id)
- return GNUNET_YES;
- fui_ctx->cqr = cqr;
- return GNUNET_NO;
-}
-
-
-/**
- * Handler for "GET result seen" messages from the client.
- *
+ * Handler for PUT messages.
* @param cls closure for the service
* @param client the client we received this message from
* @param message the actual message received
*/
static void
-handle_dht_local_get_result_seen (void *cls, struct GNUNET_SERVER_Client
*client,
- const struct GNUNET_MessageHeader *message)
+handle_dht_local_put (void *cls, struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
{
- const struct GNUNET_DHT_ClientGetResultSeenMessage *seen;
- uint16_t size;
- unsigned int hash_count;
- unsigned int old_count;
- const struct GNUNET_HashCode *hc;
- struct FindByUniqueIdContext fui_ctx;
- struct ClientQueryRecord *cqr;
-
+ struct GNUNET_DHT_ClientPutMessage *put_msg;
+ struct GNUNET_DHT_ClientPutConfirmationMessage *conf;
+ struct PendingMessage *pm;
+ uint16_t size; /* FIXME: When to use size_t and when uint16_t */
+
size = ntohs (message->size);
- if (size < sizeof (struct GNUNET_DHT_ClientGetResultSeenMessage))
+ if (size < sizeof (struct GNUNET_DHT_ClientPutMessage))
{
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- seen = (const struct GNUNET_DHT_ClientGetResultSeenMessage *) message;
- hash_count = (size - sizeof (struct GNUNET_DHT_ClientGetResultSeenMessage))
/ sizeof (struct GNUNET_HashCode);
- if (size != sizeof (struct GNUNET_DHT_ClientGetResultSeenMessage) +
hash_count * sizeof (struct GNUNET_HashCode))
- {
- GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
- }
- hc = (const struct GNUNET_HashCode*) &seen[1];
- fui_ctx.unique_id = seen->unique_id;
- fui_ctx.cqr = NULL;
- GNUNET_CONTAINER_multihashmap_get_multiple (forward_map,
- &seen->key,
- &find_by_unique_id,
- &fui_ctx);
- if (NULL == (cqr = fui_ctx.cqr))
- {
- GNUNET_break (0);
- GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return;
- }
- /* finally, update 'seen' list */
- old_count = cqr->seen_replies_count;
- GNUNET_array_grow (cqr->seen_replies,
- cqr->seen_replies_count,
- cqr->seen_replies_count + hash_count);
- memcpy (&cqr->seen_replies[old_count],
- hc,
- sizeof (struct GNUNET_HashCode) * hash_count);
-}
-
-
-/**
- * Closure for 'remove_by_unique_id'.
- */
-struct RemoveByUniqueIdContext
-{
- /**
- * Client that issued the removal request.
- */
- struct ClientList *client;
-
- /**
- * Unique ID of the request.
- */
- uint64_t unique_id;
-};
-
-
-/**
- * Iterator over hash map entries that frees all entries
- * that match the given client and unique ID.
- *
- * @param cls unique ID and client to search for in source routes
- * @param key current key code
- * @param value value in the hash map, a ClientQueryRecord
- * @return GNUNET_YES (we should continue to iterate)
- */
-static int
-remove_by_unique_id (void *cls, const struct GNUNET_HashCode * key, void
*value)
-{
- const struct RemoveByUniqueIdContext *ctx = cls;
- struct ClientQueryRecord *record = value;
-
- if (record->unique_id != ctx->unique_id)
- return GNUNET_YES;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Removing client %p's record for key %s (by unique id)\n",
- ctx->client->client_handle, GNUNET_h2s (key));
- return remove_client_records (ctx->client, key, record);
-}
-
-
-/**
- * Handler for any generic DHT stop messages, calls the appropriate handler
- * depending on message type (if processed locally)
- *
- * @param cls closure for the service
- * @param client the client we received this message from
- * @param message the actual message received
- *
- */
-static void
-handle_dht_local_get_stop (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
-{
- const struct GNUNET_DHT_ClientGetStopMessage *dht_stop_msg =
- (const struct GNUNET_DHT_ClientGetStopMessage *) message;
- struct RemoveByUniqueIdContext ctx;
-
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop
- ("# GET STOP requests received from clients"), 1,
- GNUNET_NO);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received GET STOP request for %s from local client %p\n",
- client, GNUNET_h2s (&dht_stop_msg->key));
- ctx.client = find_active_client (client);
- ctx.unique_id = dht_stop_msg->unique_id;
- GNUNET_CONTAINER_multihashmap_get_multiple (forward_map, &dht_stop_msg->key,
- &remove_by_unique_id, &ctx);
+
+ /* FIXME:Should we define put_msg as const? */
+ put_msg = (struct GNUNET_DHT_ClientPutMessage *) message;
+
+ /* store locally. FIXME: Is it secure to allow each peer to store the data?
*/
+ GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (put_msg->expiration),
+ &put_msg->key, 0, NULL, ntohl (put_msg->type),
+ size - sizeof (struct GNUNET_DHT_ClientPutMessage),
+ &put_msg[1]);
+
+ /* FIXME: Right now I have just kept all the fields from the old function.
+ It may be possible that most of them are not needed. Check and remove if
+ not needed. Usage of replication, options and type is still not clear. */
+ GDS_NEIGHBOURS_handle_put (ntohl (put_msg->type), ntohl (put_msg->options),
+ ntohl (put_msg->desired_replication_level),
+ GNUNET_TIME_absolute_ntoh (put_msg->expiration),
+ 0 /* hop count */ ,
+ &put_msg->key, 0, NULL, &put_msg[1],
+ size -
+ sizeof (struct GNUNET_DHT_ClientPutMessage),
+ NULL, NULL, NULL);
+
+ /* FIXME: Here we send back the confirmation before verifying if put was
successful
+ or not. */
+ pm = GNUNET_malloc (sizeof (struct PendingMessage) +
+ sizeof (struct GNUNET_DHT_ClientPutConfirmationMessage));
+ conf = (struct GNUNET_DHT_ClientPutConfirmationMessage *) &pm[1];
+ conf->header.size = htons (sizeof (struct
GNUNET_DHT_ClientPutConfirmationMessage));
+ conf->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT_OK);
+ conf->reserved = htonl (0);
+ conf->unique_id = put_msg->unique_id;
+ pm->msg = &conf->header;
+ add_pending_message (find_active_client (client), pm);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
-
/**
- * Handler for monitor start messages
+ * Functions with this signature are called whenever a client
+ * is disconnected on the network level.
*
- * @param cls closure for the service
- * @param client the client we received this message from
- * @param message the actual message received
- *
+ * @param cls closure (NULL for dht)
+ * @param client identification of the client; NULL
+ * for the last call when the server is destroyed
*/
static void
-handle_dht_local_monitor (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+handle_client_disconnect (void *cls,
+ struct GNUNET_SERVER_Client *client)
{
- struct ClientMonitorRecord *r;
- const struct GNUNET_DHT_MonitorStartStopMessage *msg;
-
- msg = (struct GNUNET_DHT_MonitorStartStopMessage *) message;
- r = GNUNET_new (struct ClientMonitorRecord);
-
- r->client = find_active_client(client);
- r->type = ntohl(msg->type);
- r->get = ntohs(msg->get);
- r->get_resp = ntohs(msg->get_resp);
- r->put = ntohs(msg->put);
- if (0 == ntohs(msg->filter_key))
- r->key = NULL;
- else
- {
- r->key = GNUNET_new (struct GNUNET_HashCode);
- memcpy (r->key, &msg->key, sizeof (struct GNUNET_HashCode));
- }
- GNUNET_CONTAINER_DLL_insert (monitor_head, monitor_tail, r);
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ /* You should maintain a list of client attached to this service. Then
+ search for the correct client and stop all its ongoing activites and
+ delete it from the list. */
}
-/**
- * Handler for monitor stop messages
- *
- * @param cls closure for the service
- * @param client the client we received this message from
- * @param message the actual message received
- *
- */
-static void
-handle_dht_local_monitor_stop (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
-{
- struct ClientMonitorRecord *r;
- const struct GNUNET_DHT_MonitorStartStopMessage *msg;
- int keys_match;
- msg = (struct GNUNET_DHT_MonitorStartStopMessage *) message;
- r = monitor_head;
-
- while (NULL != r)
- {
- if (NULL == r->key)
- keys_match = (0 == ntohs(msg->filter_key));
- else
- {
- keys_match = (0 != ntohs(msg->filter_key)
- && !memcmp(r->key, &msg->key, sizeof(struct
GNUNET_HashCode)));
- }
- if (find_active_client(client) == r->client
- && ntohl(msg->type) == r->type
- && r->get == msg->get
- && r->get_resp == msg->get_resp
- && r->put == msg->put
- && keys_match
- )
- {
- GNUNET_CONTAINER_DLL_remove (monitor_head, monitor_tail, r);
- GNUNET_free_non_null (r->key);
- GNUNET_free (r);
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
- return; /* Delete only ONE entry */
- }
- r = r->next;
- }
-
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
-}
-
-
/**
- * Callback called as a result of issuing a GNUNET_SERVER_notify_transmit_ready
- * request. A ClientList is passed as closure, take the head of the list
- * and copy it into buf, which has the result of sending the message to the
- * client.
- *
- * @param cls closure to this call
- * @param size maximum number of bytes available to send
- * @param buf where to copy the actual message to
- *
- * @return the number of bytes actually copied, 0 indicates failure
+ * Get result from neighbours file.
*/
-static size_t
-send_reply_to_client (void *cls, size_t size, void *buf)
-{
- struct ClientList *client = cls;
- char *cbuf = buf;
- struct PendingMessage *reply;
- size_t off;
- size_t msize;
-
- client->transmit_handle = NULL;
- if (buf == NULL)
- {
- /* client disconnected */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client %p disconnected, pending messages will be discarded\n",
- client->client_handle);
- return 0;
- }
- off = 0;
- while ((NULL != (reply = client->pending_head)) &&
- (size >= off + (msize = ntohs (reply->msg->size))))
- {
- GNUNET_CONTAINER_DLL_remove (client->pending_head, client->pending_tail,
- reply);
- memcpy (&cbuf[off], reply->msg, msize);
- GNUNET_free (reply);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting %u bytes to client
%p\n",
- msize, client->client_handle);
- off += msize;
- }
- process_pending_messages (client);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitted %u/%u bytes to client
%p\n",
- (unsigned int) off, (unsigned int) size, client->client_handle);
- return off;
-}
-
-
-/**
- * Task run to check for messages that need to be sent to a client.
- *
- * @param client a ClientList, containing the client and any messages to be
sent to it
- */
-static void
-process_pending_messages (struct ClientList *client)
-{
- if ((client->pending_head == NULL) || (client->transmit_handle != NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Not asking for transmission to %p now: %s\n",
- client->client_handle,
- client->pending_head ==
- NULL ? "no more messages" : "request already pending");
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Asking for transmission of %u bytes to client %p\n",
- ntohs (client->pending_head->msg->size), client->client_handle);
- client->transmit_handle =
- GNUNET_SERVER_notify_transmit_ready (client->client_handle,
- ntohs (client->pending_head->
- msg->size),
- GNUNET_TIME_UNIT_FOREVER_REL,
- &send_reply_to_client, client);
-}
-
-
-/**
- * Closure for 'forward_reply'
- */
-struct ForwardReplyContext
-{
-
- /**
- * Actual message to send to matching clients.
- */
- struct PendingMessage *pm;
-
- /**
- * Embedded payload.
- */
- const void *data;
-
- /**
- * Type of the data.
- */
- enum GNUNET_BLOCK_Type type;
-
- /**
- * Number of bytes in data.
- */
- size_t data_size;
-
- /**
- * Do we need to copy 'pm' because it was already used?
- */
- int do_copy;
-
-};
-
-
-/**
- * Iterator over hash map entries that send a given reply to
- * each of the matching clients. With some tricky recycling
- * of the buffer.
- *
- * @param cls the 'struct ForwardReplyContext'
- * @param key current key
- * @param value value in the hash map, a ClientQueryRecord
- * @return GNUNET_YES (we should continue to iterate),
- * if the result is mal-formed, GNUNET_NO
- */
-static int
-forward_reply (void *cls, const struct GNUNET_HashCode * key, void *value)
-{
- struct ForwardReplyContext *frc = cls;
- struct ClientQueryRecord *record = value;
- struct PendingMessage *pm;
- struct GNUNET_DHT_ClientResultMessage *reply;
- enum GNUNET_BLOCK_EvaluationResult eval;
- int do_free;
- struct GNUNET_HashCode ch;
- unsigned int i;
-
- LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG,
- "XDHT CLIENT-RESULT %s\n",
- GNUNET_h2s (key));
- if ((record->type != GNUNET_BLOCK_TYPE_ANY) && (record->type != frc->type))
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Record type missmatch, not passing request for key %s to local
client\n",
- GNUNET_h2s (key));
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop
- ("# Key match, type mismatches in REPLY to
CLIENT"),
- 1, GNUNET_NO);
- return GNUNET_YES; /* type mismatch */
- }
- GNUNET_CRYPTO_hash (frc->data, frc->data_size, &ch);
- for (i = 0; i < record->seen_replies_count; i++)
- if (0 == memcmp (&record->seen_replies[i], &ch, sizeof (struct
GNUNET_HashCode)))
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Duplicate reply, not passing request for key %s to local client\n",
- GNUNET_h2s (key));
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop
- ("# Duplicate REPLIES to CLIENT request
dropped"),
- 1, GNUNET_NO);
- return GNUNET_YES; /* duplicate */
- }
- eval =
- GNUNET_BLOCK_evaluate (GDS_block_context, record->type, key, NULL, 0,
- record->xquery, record->xquery_size, frc->data,
- frc->data_size);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Evaluation result is %d for key %s for local client's query\n",
- (int) eval, GNUNET_h2s (key));
- switch (eval)
- {
- case GNUNET_BLOCK_EVALUATION_OK_LAST:
- do_free = GNUNET_YES;
- break;
- case GNUNET_BLOCK_EVALUATION_OK_MORE:
- GNUNET_array_append (record->seen_replies, record->seen_replies_count, ch);
- do_free = GNUNET_NO;
- break;
- case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
- /* should be impossible to encounter here */
- GNUNET_break (0);
- return GNUNET_YES;
- case GNUNET_BLOCK_EVALUATION_RESULT_INVALID:
- GNUNET_break_op (0);
- return GNUNET_NO;
- case GNUNET_BLOCK_EVALUATION_REQUEST_VALID:
- GNUNET_break (0);
- return GNUNET_NO;
- case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID:
- GNUNET_break (0);
- return GNUNET_NO;
- case GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT:
- return GNUNET_YES;
- case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Unsupported block type (%u) in request!\n"), record->type);
- return GNUNET_NO;
- default:
- GNUNET_break (0);
- return GNUNET_NO;
- }
- if (GNUNET_NO == frc->do_copy)
- {
- /* first time, we can use the original data */
- pm = frc->pm;
- frc->do_copy = GNUNET_YES;
- }
- else
- {
- /* two clients waiting for same reply, must copy for queueing */
- pm = GNUNET_malloc (sizeof (struct PendingMessage) +
- ntohs (frc->pm->msg->size));
- memcpy (pm, frc->pm,
- sizeof (struct PendingMessage) + ntohs (frc->pm->msg->size));
- pm->next = pm->prev = NULL;
- pm->msg = (struct GNUNET_MessageHeader *) &pm[1];
- }
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop ("# RESULTS queued for clients"), 1,
- GNUNET_NO);
- reply = (struct GNUNET_DHT_ClientResultMessage *) &pm[1];
- reply->unique_id = record->unique_id;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Queueing reply to query %s for client %p\n",
- GNUNET_h2s (key),
- record->client->client_handle);
- add_pending_message (record->client, pm);
- if (GNUNET_YES == do_free)
- remove_client_records (record->client, key, record);
- return GNUNET_YES;
-}
-
-
-/**
- * Handle a reply we've received from another peer. If the reply
- * matches any of our pending queries, forward it to the respective
- * client(s).
- *
- * @param expiration when will the reply expire
- * @param key the query this reply is for
- * @param get_path_length number of peers in @a get_path
- * @param get_path path the reply took on get
- * @param put_path_length number of peers in @a put_path
- * @param put_path path the reply took on put
- * @param type type of the reply
- * @param data_size number of bytes in @a data
- * @param data application payload data
- */
void
-GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
- const struct GNUNET_HashCode *key,
- unsigned int get_path_length,
- const struct GNUNET_PeerIdentity *get_path,
- unsigned int put_path_length,
- const struct GNUNET_PeerIdentity *put_path,
- enum GNUNET_BLOCK_Type type, size_t data_size,
- const void *data)
+GDS_CLIENTS_process_get_result()
{
- struct ForwardReplyContext frc;
- struct PendingMessage *pm;
- struct GNUNET_DHT_ClientResultMessage *reply;
- struct GNUNET_PeerIdentity *paths;
- size_t msize;
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "reply for key %s\n",
- GNUNET_h2s (key));
-
- if (NULL == GNUNET_CONTAINER_multihashmap_get (forward_map, key))
- {
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop
- ("# REPLIES ignored for CLIENTS (no match)"), 1,
- GNUNET_NO);
- return; /* no matching request, fast exit! */
- }
- msize =
- sizeof (struct GNUNET_DHT_ClientResultMessage) + data_size +
- (get_path_length + put_path_length) * sizeof (struct
GNUNET_PeerIdentity);
- if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Could not pass reply to client, message too big!\n"));
- return;
- }
- pm = GNUNET_malloc (msize + sizeof (struct PendingMessage));
- reply = (struct GNUNET_DHT_ClientResultMessage *) &pm[1];
- pm->msg = &reply->header;
- reply->header.size = htons ((uint16_t) msize);
- reply->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT);
- reply->type = htonl (type);
- reply->get_path_length = htonl (get_path_length);
- reply->put_path_length = htonl (put_path_length);
- reply->unique_id = 0; /* filled in later */
- reply->expiration = GNUNET_TIME_absolute_hton (expiration);
- reply->key = *key;
- paths = (struct GNUNET_PeerIdentity *) &reply[1];
- memcpy (paths, put_path,
- sizeof (struct GNUNET_PeerIdentity) * put_path_length);
- memcpy (&paths[put_path_length], get_path,
- sizeof (struct GNUNET_PeerIdentity) * get_path_length);
- memcpy (&paths[get_path_length + put_path_length], data, data_size);
- frc.do_copy = GNUNET_NO;
- frc.pm = pm;
- frc.data = data;
- frc.data_size = data_size;
- frc.type = type;
- GNUNET_CONTAINER_multihashmap_get_multiple (forward_map, key, &forward_reply,
- &frc);
- if (GNUNET_NO == frc.do_copy)
- {
- /* did not match any of the requests, free! */
- GNUNET_STATISTICS_update (GDS_stats,
- gettext_noop
- ("# REPLIES ignored for CLIENTS (no match)"), 1,
- GNUNET_NO);
- GNUNET_free (pm);
- }
+
}
/**
- * Check if some client is monitoring GET messages and notify
- * them in that case.
- *
- * @param options Options, for instance RecordRoute, DemultiplexEverywhere.
- * @param type The type of data in the request.
- * @param hop_count Hop count so far.
- * @param path_length number of entries in path (or 0 if not recorded).
- * @param path peers on the GET path (or NULL if not recorded).
- * @param desired_replication_level Desired replication level.
- * @param key Key of the requested data.
- */
-void
-GDS_CLIENTS_process_get (uint32_t options,
- enum GNUNET_BLOCK_Type type,
- uint32_t hop_count,
- uint32_t desired_replication_level,
- unsigned int path_length,
- const struct GNUNET_PeerIdentity *path,
- const struct GNUNET_HashCode * key)
-{
- struct ClientMonitorRecord *m;
- struct ClientList **cl;
- unsigned int cl_size;
-
- cl = NULL;
- cl_size = 0;
- for (m = monitor_head; NULL != m; m = m->next)
- {
- if ((GNUNET_BLOCK_TYPE_ANY == m->type || m->type == type) &&
- (NULL == m->key ||
- memcmp (key, m->key, sizeof(struct GNUNET_HashCode)) == 0))
- {
- struct PendingMessage *pm;
- struct GNUNET_DHT_MonitorGetMessage *mmsg;
- struct GNUNET_PeerIdentity *msg_path;
- size_t msize;
- unsigned int i;
-
- /* Don't send duplicates */
- for (i = 0; i < cl_size; i++)
- if (cl[i] == m->client)
- break;
- if (i < cl_size)
- continue;
- GNUNET_array_append (cl, cl_size, m->client);
-
- msize = path_length * sizeof (struct GNUNET_PeerIdentity);
- msize += sizeof (struct GNUNET_DHT_MonitorGetMessage);
- msize += sizeof (struct PendingMessage);
- pm = GNUNET_malloc (msize);
- mmsg = (struct GNUNET_DHT_MonitorGetMessage *) &pm[1];
- pm->msg = &mmsg->header;
- mmsg->header.size = htons (msize - sizeof (struct PendingMessage));
- mmsg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET);
- mmsg->options = htonl(options);
- mmsg->type = htonl(type);
- mmsg->hop_count = htonl(hop_count);
- mmsg->desired_replication_level = htonl(desired_replication_level);
- mmsg->get_path_length = htonl(path_length);
- memcpy (&mmsg->key, key, sizeof (struct GNUNET_HashCode));
- msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1];
- if (path_length > 0)
- memcpy (msg_path, path,
- path_length * sizeof (struct GNUNET_PeerIdentity));
- add_pending_message (m->client, pm);
- }
- }
- GNUNET_free_non_null (cl);
-}
-
-
-/**
- * Check if some client is monitoring GET RESP messages and notify
- * them in that case.
- *
- * @param type The type of data in the result.
- * @param get_path Peers on GET path (or NULL if not recorded).
- * @param get_path_length number of entries in get_path.
- * @param put_path peers on the PUT path (or NULL if not recorded).
- * @param put_path_length number of entries in get_path.
- * @param exp Expiration time of the data.
- * @param key Key of the data.
- * @param data Pointer to the result data.
- * @param size Number of bytes in data.
- */
-void
-GDS_CLIENTS_process_get_resp (enum GNUNET_BLOCK_Type type,
- const struct GNUNET_PeerIdentity *get_path,
- unsigned int get_path_length,
- const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_length,
- struct GNUNET_TIME_Absolute exp,
- const struct GNUNET_HashCode * key,
- const void *data,
- size_t size)
-{
- struct ClientMonitorRecord *m;
- struct ClientList **cl;
- unsigned int cl_size;
-
- cl = NULL;
- cl_size = 0;
- for (m = monitor_head; NULL != m; m = m->next)
- {
- if ((GNUNET_BLOCK_TYPE_ANY == m->type || m->type == type) &&
- (NULL == m->key ||
- memcmp (key, m->key, sizeof(struct GNUNET_HashCode)) == 0))
- {
- struct PendingMessage *pm;
- struct GNUNET_DHT_MonitorGetRespMessage *mmsg;
- struct GNUNET_PeerIdentity *path;
- size_t msize;
- unsigned int i;
-
- /* Don't send duplicates */
- for (i = 0; i < cl_size; i++)
- if (cl[i] == m->client)
- break;
- if (i < cl_size)
- continue;
- GNUNET_array_append (cl, cl_size, m->client);
-
- msize = size;
- msize += (get_path_length + put_path_length)
- * sizeof (struct GNUNET_PeerIdentity);
- msize += sizeof (struct GNUNET_DHT_MonitorGetRespMessage);
- msize += sizeof (struct PendingMessage);
- pm = GNUNET_malloc (msize);
- mmsg = (struct GNUNET_DHT_MonitorGetRespMessage *) &pm[1];
- pm->msg = (struct GNUNET_MessageHeader *) mmsg;
- mmsg->header.size = htons (msize - sizeof (struct PendingMessage));
- mmsg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET_RESP);
- mmsg->type = htonl(type);
- mmsg->put_path_length = htonl(put_path_length);
- mmsg->get_path_length = htonl(get_path_length);
- path = (struct GNUNET_PeerIdentity *) &mmsg[1];
- if (put_path_length > 0)
- {
- memcpy (path, put_path,
- put_path_length * sizeof (struct GNUNET_PeerIdentity));
- path = &path[put_path_length];
- }
- if (get_path_length > 0)
- memcpy (path, get_path,
- get_path_length * sizeof (struct GNUNET_PeerIdentity));
- mmsg->expiration_time = GNUNET_TIME_absolute_hton(exp);
- memcpy (&mmsg->key, key, sizeof (struct GNUNET_HashCode));
- if (size > 0)
- memcpy (&path[get_path_length], data, size);
- add_pending_message (m->client, pm);
- }
- }
- GNUNET_free_non_null (cl);
-}
-
-
-/**
- * Check if some client is monitoring PUT messages and notify
- * them in that case.
- *
- * @param options Options, for instance RecordRoute, DemultiplexEverywhere.
- * @param type The type of data in the request.
- * @param hop_count Hop count so far.
- * @param path_length number of entries in path (or 0 if not recorded).
- * @param path peers on the PUT path (or NULL if not recorded).
- * @param desired_replication_level Desired replication level.
- * @param exp Expiration time of the data.
- * @param key Key under which data is to be stored.
- * @param data Pointer to the data carried.
- * @param size Number of bytes in data.
- */
-void
-GDS_CLIENTS_process_put (uint32_t options,
- enum GNUNET_BLOCK_Type type,
- uint32_t hop_count,
- uint32_t desired_replication_level,
- unsigned int path_length,
- const struct GNUNET_PeerIdentity *path,
- struct GNUNET_TIME_Absolute exp,
- const struct GNUNET_HashCode * key,
- const void *data,
- size_t size)
-{
- struct ClientMonitorRecord *m;
- struct ClientList **cl;
- unsigned int cl_size;
-
- cl = NULL;
- cl_size = 0;
- for (m = monitor_head; NULL != m; m = m->next)
- {
- if ((GNUNET_BLOCK_TYPE_ANY == m->type || m->type == type) &&
- (NULL == m->key ||
- memcmp (key, m->key, sizeof(struct GNUNET_HashCode)) == 0))
- {
- struct PendingMessage *pm;
- struct GNUNET_DHT_MonitorPutMessage *mmsg;
- struct GNUNET_PeerIdentity *msg_path;
- size_t msize;
- unsigned int i;
-
- /* Don't send duplicates */
- for (i = 0; i < cl_size; i++)
- if (cl[i] == m->client)
- break;
- if (i < cl_size)
- continue;
- GNUNET_array_append (cl, cl_size, m->client);
-
- msize = size;
- msize += path_length * sizeof (struct GNUNET_PeerIdentity);
- msize += sizeof (struct GNUNET_DHT_MonitorPutMessage);
- msize += sizeof (struct PendingMessage);
- pm = GNUNET_malloc (msize);
- mmsg = (struct GNUNET_DHT_MonitorPutMessage *) &pm[1];
- pm->msg = (struct GNUNET_MessageHeader *) mmsg;
- mmsg->header.size = htons (msize - sizeof (struct PendingMessage));
- mmsg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT);
- mmsg->options = htonl(options);
- mmsg->type = htonl(type);
- mmsg->hop_count = htonl(hop_count);
- mmsg->desired_replication_level = htonl(desired_replication_level);
- mmsg->put_path_length = htonl(path_length);
- msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1];
- if (path_length > 0)
- {
- memcpy (msg_path, path,
- path_length * sizeof (struct GNUNET_PeerIdentity));
- }
- mmsg->expiration_time = GNUNET_TIME_absolute_hton(exp);
- memcpy (&mmsg->key, key, sizeof (struct GNUNET_HashCode));
- if (size > 0)
- memcpy (&msg_path[path_length], data, size);
- add_pending_message (m->client, pm);
- }
- }
- GNUNET_free_non_null (cl);
-}
-
-
-/**
+ * SUPU: Call to this function is made from gnunet-service-xdht.c
+ * Here we register handlers for each possible kind of message the service
+ * receives from the clients.
* Initialize client subsystem.
*
* @param server the initialized server
@@ -1476,42 +456,19 @@
{&handle_dht_local_monitor_stop, NULL,
GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP,
sizeof (struct GNUNET_DHT_MonitorStartStopMessage)},
- {&handle_dht_local_get_result_seen, NULL,
- GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN, 0},
{NULL, NULL, 0, 0}
};
- forward_map = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_NO);
- retry_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
+
GNUNET_SERVER_add_handlers (server, plugin_handlers);
GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
}
-
/**
+ * SUPU: Call made from gnunet-service-dht.c
* Shutdown client subsystem.
*/
void
GDS_CLIENTS_done ()
{
- GNUNET_assert (client_head == NULL);
- GNUNET_assert (client_tail == NULL);
- if (GNUNET_SCHEDULER_NO_TASK != retry_task)
- {
- GNUNET_SCHEDULER_cancel (retry_task);
- retry_task = GNUNET_SCHEDULER_NO_TASK;
- }
- if (NULL != retry_heap)
- {
- GNUNET_assert (0 == GNUNET_CONTAINER_heap_get_size (retry_heap));
- GNUNET_CONTAINER_heap_destroy (retry_heap);
- retry_heap = NULL;
- }
- if (NULL != forward_map)
- {
- GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (forward_map));
- GNUNET_CONTAINER_multihashmap_destroy (forward_map);
- forward_map = NULL;
- }
-}
-
-/* end of gnunet-service-dht_clients.c */
+
+}
\ No newline at end of file
Modified: gnunet/src/dht/gnunet-service-xdht_clients.h
===================================================================
--- gnunet/src/dht/gnunet-service-xdht_clients.h 2014-03-28 08:41:34 UTC
(rev 32818)
+++ gnunet/src/dht/gnunet-service-xdht_clients.h 2014-03-28 10:24:39 UTC
(rev 32819)
@@ -21,8 +21,7 @@
/**
* @file dht/gnunet-service-xdht_clients.h
* @brief GNUnet DHT service's client management code
- * @author Christian Grothoff
- * @author Nathan Evans
+ * @author Supriti Singh
*/
#ifndef GNUNET_SERVICE_XDHT_CLIENT_H
#define GNUNET_SERVICE_XDHT_CLIENT_H
@@ -130,6 +129,12 @@
size_t size);
/**
+ *
+ */
+void
+GDS_CLIENTS_process_get_result();
+
+/**
* Initialize client subsystem.
*
* @param server the initialized server
Modified: gnunet/src/dht/gnunet-service-xdht_datacache.c
===================================================================
--- gnunet/src/dht/gnunet-service-xdht_datacache.c 2014-03-28 08:41:34 UTC
(rev 32818)
+++ gnunet/src/dht/gnunet-service-xdht_datacache.c 2014-03-28 10:24:39 UTC
(rev 32819)
@@ -164,8 +164,8 @@
gettext_noop
("# Good RESULTS found in datacache"), 1,
GNUNET_NO);
- GDS_CLIENTS_handle_reply (exp, key, 0, NULL, put_path_length, put_path,
- type, size, data);
+ /* GDS_CLIENTS_handle_reply (exp, key, 0, NULL, put_path_length, put_path,
+ type, size, data);*/
/* forward to other peers */
GDS_ROUTING_process (type, exp, key, put_path_length, put_path, 0, NULL,
data, size);
Modified: gnunet/src/dht/gnunet-service-xdht_neighbours.c
===================================================================
--- gnunet/src/dht/gnunet-service-xdht_neighbours.c 2014-03-28 08:41:34 UTC
(rev 32818)
+++ gnunet/src/dht/gnunet-service-xdht_neighbours.c 2014-03-28 10:24:39 UTC
(rev 32819)
@@ -51,7 +51,13 @@
/* TODO:
1. Use a global array of all known peers in find_successor, Only when
a new peer is added in finger or friend peer map, then re calculate
- the array. Or else use the old one. */
+ the array. Or else use the old one.
+ 2. Should we be using const in all the handle for the message we received
+ * and then copy the fields and make changes to the fields instead of sending
+ * them as they come.
+ * 3. Everywhere you are storing yourself as the first element in the trail.
+ * It is obviously taking too much space. Try to remove it and think of
something
+ * better. */
/**
* Maximum possible fingers of a peer.
@@ -78,7 +84,21 @@
*/
#define GET_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 2)
+/**
+ * FIXME: Use this variable. Should it be moved to routing.c
+ * Threshold on routing table entries for a peer.
+ */
+#define ROUTING_TABLE_THRESHOLD 64
+/**
+ * FIXME: Use this variable. When adding an entry in finger table, check
+ * this threshold value. At the moment, its just a random value. Also,
+ * implement teardown feature from the paper.
+ * Threshold on number of peers in a trail length
+ */
+#define TRAIL_LENGTH_THRESHOLD 64
+
+
GNUNET_NETWORK_STRUCT_BEGIN
/**
@@ -115,50 +135,66 @@
* Length of the PUT path that follows (if tracked).
*/
uint32_t put_path_length GNUNET_PACKED;
+
+ /**
+ * Source peer
+ */
+ struct GNUNET_PeerIdentity source_peer;
+
+ /**
+ * Current destination
+ */
+ struct GNUNET_PeerIdentity current_destination;
+
+ /**
+ * Current destination type
+ */
+ enum current_destination_type current_destination_type;
/**
* When does the content expire?
*/
struct GNUNET_TIME_AbsoluteNBO expiration_time;
-
+
/**
- * Bloomfilter (for peer identities) to stop circular routes
+ * The key to store the value under.
*/
- char bloomfilter[DHT_BLOOM_SIZE];
+ struct GNUNET_HashCode key GNUNET_PACKED;
+
- /**
- * The key we are storing under.
- */
- struct GNUNET_HashCode key;
-
/* put path (if tracked) */
/* Payload */
-
+
};
/**
* P2P Result message
*/
-struct PeerResultMessage
+struct PeerGetResultMessage
{
/**
- * Type: #GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT
+ * Type: #GNUNET_MESSAGE_TYPE_DHT_P2P_GET_RESULT
*/
struct GNUNET_MessageHeader header;
/**
- * Content type.
+ * Peer which is sending get result message.
*/
- uint32_t type GNUNET_PACKED;
-
+ struct GNUNET_PeerIdentity source_peer;
+
/**
- * Length of the PUT path that follows (if tracked).
+ * Peer which will receive the get result message.
*/
- uint32_t put_path_length GNUNET_PACKED;
+ struct GNUNET_PeerIdentity destination_peer;
/**
+ * Current index in get path.
+ */
+ unsigned int current_path_index;
+
+ /**
* Length of the GET path that follows (if tracked).
*/
uint32_t get_path_length GNUNET_PACKED;
@@ -191,65 +227,43 @@
* Type: #GNUNET_MESSAGE_TYPE_DHT_P2P_GET
*/
struct GNUNET_MessageHeader header;
-
+
/**
- * Processing options
+ * Source peer
*/
- uint32_t options GNUNET_PACKED;
+ struct GNUNET_PeerIdentity source_peer;
/**
- * Desired content type.
+ * Total number of peers in get path.
*/
- uint32_t type GNUNET_PACKED;
-
+ unsigned int get_path_length;
+
/**
- * Hop count
+ *
*/
- uint32_t hop_count GNUNET_PACKED;
+ struct GNUNET_PeerIdentity current_destination;
/**
- * Desired replication level for this request.
+ *
*/
- uint32_t desired_replication_level GNUNET_PACKED;
-
+ enum current_destination_type dest_type;
+
/**
- * Size of the extended query.
+ * When does the content expire?
*/
- uint32_t xquery_size;
-
+ struct GNUNET_TIME_AbsoluteNBO expiration_time;
+
/**
- * Bloomfilter mutator.
- */
- uint32_t bf_mutator;
-
- /**
- * Bloomfilter (for peer identities) to stop circular routes
- */
- char bloomfilter[DHT_BLOOM_SIZE];
-
- /**
* The key we are looking for.
*/
struct GNUNET_HashCode key;
+
+ /* Get path. */
};
/**
- * FIXME: Change the comment to explain about usage of this in find successor.
- * Field in trail setup message to understand if the message is sent to an
- * intermediate finger, friend or me.
- */
-enum current_destination_type
-{
- FRIEND ,
- FINGER ,
- MY_ID ,
- VALUE
-};
-
-
-/**
* P2P Trail setup message
*/
struct PeerTrailSetupMessage
@@ -1044,93 +1058,6 @@
}
-/**FIXME: Old implementation just to remove error
- * TODO: Modify this function to handle our get request.
- * Perform a GET operation. Forwards the given request to other
- * peers. Does not lookup the key locally. May do nothing if this is
- * the only peer in the network (or if we are the closest peer in the
- * network).
- *
- * @param type type of the block
- * @param options routing options
- * @param desired_replication_level desired replication count
- * @param hop_count how many hops did this request traverse so far?
- * @param key key for the content
- * @param xquery extended query
- * @param xquery_size number of bytes in @a xquery
- * @param reply_bf bloomfilter to filter duplicates
- * @param reply_bf_mutator mutator for @a reply_bf
- * @param peer_bf filter for peers not to select (again)
- */
-void
-GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
- enum GNUNET_DHT_RouteOption options,
- uint32_t desired_replication_level,
- uint32_t hop_count, const struct GNUNET_HashCode *
key,
- const void *xquery, size_t xquery_size,
- const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
- uint32_t reply_bf_mutator,
- struct GNUNET_CONTAINER_BloomFilter *peer_bf)
-{
-
- /*
- 1. take the key, get the 64 bit value of the key.
- 2. call find_successor to get the successor of the key.
- 3. successor can be either a friend or finger.
- 4. update the field in get message to reflect if its a friend or finger
table
- 5. add the put message to pending message and send it.
- */
-
-}
-
-/**FIXME: Old implementation just to remove error.
- * TODO: Modify this function to handle our put request.
- * Perform a PUT operation. Forwards the given request to other
- * peers. Does not store the data locally. Does not give the
- * data to local clients. May do nothing if this is the only
- * peer in the network (or if we are the closest peer in the
- * network).
- *
- * @param type type of the block
- * @param options routing options
- * @param desired_replication_level desired replication count
- * @param expiration_time when does the content expire
- * @param hop_count how many hops has this message traversed so far
- * @param bf Bloom filter of peers this PUT has already traversed
- * @param key key for the content
- * @param put_path_length number of entries in @a put_path
- * @param put_path peers this request has traversed so far (if tracked)
- * @param data payload to store
- * @param data_size number of bytes in @a data
- */
-void
-GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
- enum GNUNET_DHT_RouteOption options,
- uint32_t desired_replication_level,
- struct GNUNET_TIME_Absolute expiration_time,
- uint32_t hop_count,
- struct GNUNET_CONTAINER_BloomFilter *bf,
- const struct GNUNET_HashCode *key,
- unsigned int put_path_length,
- struct GNUNET_PeerIdentity *put_path,
- const void *data, size_t data_size)
-{
-
- /*
- 1. take the key, get the 64 bit value of the key.
- 2. call find_successor to get the successor of the key.
- 3. successor can be either a friend or finger.
- 4. update the field in put message to reflect if its a friend or finger
table
- 5. add the put message to pending message and send it.
- */
- /* SUPU: Call is made to this function from client. It does not seem to be
- waiting for a confirmation So, once we got the request, we use the key and
- try to find the closest successor, but in this case when we reach to the
- closest successor in handle_dht_p2p_put, then just do datacache_put. As the
calling
- function does not need any confirmation, we don't need the result back. */
-}
-
-
/**
* Randomly choose one of your friends from the friends_peer map
* @return Friend
@@ -1468,64 +1395,13 @@
const struct GNUNET_PeerIdentity *identity)
{
my_identity = *identity;
-
+
}
-/**
- * Core handler for p2p put requests.
- *
- * @param cls closure
- * @param peer sender of the request
- * @param message message
- * @param peer peer identity this notification is about
- * @return #GNUNET_OK to keep the connection open,
- * #GNUNET_SYSERR to close it (signal serious error)
- */
-static int
-handle_dht_p2p_put (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_MessageHeader *message)
-{
- /**
- 1. Check if destination is friend or finger.
- 2. If finger then get the next hop from routing table and
- * call GDS_NEGIHBOURS_handle_get.
- 3. If friend then call find_successor to get the next hop and again
- * call GDS_NEIGHBOURS_handle_get to send to chosen hop.
- 4. If you are the destination then do datacache_store.
- */
- return 0;
-}
-/**
- * Core handler for p2p get requests.
- *
- * @param cls closure
- * @param peer sender of the request
- * @param message message
- * @return #GNUNET_OK to keep the connection open,
- * #GNUNET_SYSERR to close it (signal serious error)
- */
-static int
-handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_MessageHeader *message)
-{
- /**
- 1. Check if destination is friend or finger.
- 2. If finger then get the next hop from routing table and
- * call GDS_NEGIHBOURS_handle_get.
- 3. If friend then call find_successor to get the next hop and again
- * call GDS_NEIGHBOURS_handle_get to send to chosen hop.
- 4. If you are the destination then send the data back to source peer
- * Assuming we have trail setup we can
- * either store the whole trail or again do the search process..
- */
- return 0;
-}
-
/**
* FIXME: When we add a successor or predecessor should we check the entry in
* finger map index. If we don't replace the old entry then should we notify
@@ -1665,7 +1541,7 @@
/**
- * Return the previous element of value in all_known_peers.
+ * Return the successor of value in all_known_peers.
* @param all_known_peers list of all the peers
* @param value value we have to search in the all_known_peers.
* @return
@@ -1719,7 +1595,7 @@
* @return Peer identity of next destination i.e. successor of value.
*/
static struct GNUNET_PeerIdentity *
-find_successor(uint64_t value, struct GNUNET_PeerIdentity *current_destination,
+find_successor (uint64_t value, struct GNUNET_PeerIdentity
*current_destination,
enum current_destination_type *type)
{
struct GNUNET_CONTAINER_MultiPeerMapIterator *friend_iter;
@@ -1825,7 +1701,512 @@
}
}
+#if 0
+static void
+replicate_put()
+{
+ /* In this function, you should find 'r' (r = desired replication level)
successors
+ and send put message to all of these r successors. Now, I really don't know
+ if in case of node failure it will be able to find data. Or if we start with
+ a random peer id, do we even reach to correct successor ever in case of
+ get. */
+}
+#endif
+/**
+ *
+ * @param source_peer
+ * @param get_path
+ * @param get_path_length
+ * @param key
+ */
+void
+GDS_NEIGHBOURS_handle_get (struct GNUNET_PeerIdentity *source_peer,
+ struct GNUNET_PeerIdentity *get_path,
+ unsigned int get_path_length,
+ struct GNUNET_HashCode *key,
+ struct GNUNET_PeerIdentity *target_peer,
+ struct GNUNET_PeerIdentity *current_destination,
+ enum current_destination_type *type)
+{
+ struct PeerGetMessage *get_msg;
+ struct P2PPendingMessage *pending;
+ struct GNUNET_PeerIdentity *gp;
+ struct FriendInfo *target_friend;
+ uint64_t key_value;
+ size_t msize;
+
+ msize = sizeof (struct PeerGetMessage) +
+ (get_path_length * sizeof (struct GNUNET_PeerIdentity));
+
+ if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ {
+ GNUNET_break (0);
+ return;
+ }
+
+ memcpy (&key_value, key, sizeof (uint64_t));
+
+ if (NULL == target_peer)
+ {
+ /* This is the first call made from client file. */
+ struct GNUNET_PeerIdentity *next_hop;
+ next_hop = find_successor (key_value, current_destination, type);
+
+ if (*type == MY_ID)
+ {
+ struct GNUNET_PeerIdentity *destination_peer;
+ int current_path_index;
+
+ /* FIXME: You enter in this part of code only if the call is made from
the
+ client file. And in client file you already have done the datacache_get.
+ So, ideally you don't need it. Remove it after checking. */
+ if (get_path_length != 1)
+ current_path_index = get_path_length - 2;
+ destination_peer = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
+ memcpy (destination_peer, source_peer, sizeof (struct
GNUNET_PeerIdentity));
+ /* I am the final destination, then call
GDS_NEIGHBOURS_send_get_result.*/
+ GDS_NEIGHBOURS_send_get_result (&my_identity,get_path, get_path_length,
+ destination_peer, current_path_index);
+ return;
+ }
+ else
+ {
+ /* Find the friend corresponding to next_hop */
+ target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap,
next_hop);
+ }
+ }
+ else
+ target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap,
target_peer);
+
+ pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
+ pending->importance = 0; /* FIXME */
+ /* FIXME: Do we have an expiration time for get request */
+ get_msg = (struct PeerGetMessage *) &pending[1];
+ pending->msg = &get_msg->header;
+ get_msg->header.size = htons (msize);
+ get_msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_GET);
+ get_msg->get_path_length = htonl (get_path_length);
+ get_msg->key = *key;
+ memcpy (&(get_msg->source_peer), source_peer, sizeof (struct
GNUNET_PeerIdentity));
+ memcpy (&(get_msg->current_destination), current_destination, sizeof (struct
GNUNET_PeerIdentity));
+ get_msg->dest_type = htonl (*type);
+
+ gp = (struct GNUNET_PeerIdentity *) &get_msg[1];
+ memcpy (gp, get_path, get_path_length * sizeof (struct GNUNET_PeerIdentity));
+ GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail,
pending);
+ target_friend->pending_count++;
+ process_friend_queue (target_friend);
+
+}
+
+
+/**
+ * FIXME: In this function, you just find the target friend and send the
message
+ * to next peer. In handle_dht_p2p_put, you should check the options and type
+ * and check if you are final destination or not. if not then find the next
+ * destination and send the message forward.
+ * @param type type of the block
+ * @param options routing options
+ * @param desired_replication_level desired replication count
+ * @param expiration_time when does the content expire
+ * @param hop_count how many hops has this message traversed so far
+ * @param key key for the content
+ * @param put_path_length number of entries in @a put_path
+ * @param put_path peers this request has traversed so far (if tracked)
+ * @param data payload to store
+ * @param data_size number of bytes in @a data
+ * @param current_destination
+ * @param dest_type
+ * @param target_peer_id
+ */
+void
+GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
+ enum GNUNET_DHT_RouteOption options,
+ uint32_t desired_replication_level,
+ struct GNUNET_TIME_Absolute expiration_time,
+ uint32_t hop_count,
+ struct GNUNET_HashCode *key,
+ unsigned int put_path_length,
+ struct GNUNET_PeerIdentity *put_path,
+ const void *data, size_t data_size,
+ struct GNUNET_PeerIdentity *current_destination,
+ enum current_destination_type *dest_type,
+ struct GNUNET_PeerIdentity *target_peer)
+{
+ struct PeerPutMessage *ppm;
+ struct P2PPendingMessage *pending;
+ struct FriendInfo *target_friend;
+ struct GNUNET_PeerIdentity *pp;
+ size_t msize;
+ uint64_t key_value;
+
+ msize = put_path_length * sizeof (struct GNUNET_PeerIdentity) + data_size +
+ sizeof (struct PeerPutMessage);
+
+ if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ {
+ put_path_length = 0;
+ msize = data_size + sizeof (struct PeerPutMessage);
+ }
+
+ if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ {
+ GNUNET_break (0);
+ return;
+ }
+
+ memcpy (&key_value, key, sizeof (uint64_t));
+ if (target_peer == NULL)
+ {
+ /* This is the first time the call has been made from
handle_dht_local_put.
+ So, you need to search for the next peer to send this message to. */
+ struct GNUNET_PeerIdentity *next_hop;
+ next_hop = find_successor (key_value, current_destination, dest_type);
+
+ if (*dest_type == MY_ID)
+ {
+ /* FIXME: How do we handle different block types? */
+ /* FIXME: Here depending on the replication level choose 'r' successors
+ to this peer and send put to all of these peers. */
+ //replicate_put();
+ GDS_DATACACHE_handle_put (expiration_time, key, put_path_length,
put_path,
+ type, data_size, data);
+ return;
+ }
+ else
+ {
+ /* Find the friend corresponding to next_hop */
+ target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap,
next_hop);
+ }
+ }
+ else
+ target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap,
target_peer);
+
+ pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
+ pending->importance = 0; /* FIXME */
+ pending->timeout = expiration_time;
+ ppm = (struct PeerPutMessage *) &pending[1];
+ pending->msg = &ppm->header;
+ ppm->header.size = htons (msize);
+ ppm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_PUT);
+ ppm->options = htonl (options);
+ ppm->type = htonl (type);
+ ppm->hop_count = htonl (hop_count + 1);
+ ppm->desired_replication_level = htonl (desired_replication_level);
+ ppm->put_path_length = htonl (put_path_length);
+ ppm->expiration_time = GNUNET_TIME_absolute_hton (expiration_time);
+ memcpy (&(ppm->current_destination), current_destination, sizeof (struct
GNUNET_PeerIdentity));
+ ppm->current_destination_type = htonl (*dest_type);
+ ppm->key = *key;
+
+ pp = (struct GNUNET_PeerIdentity *) &ppm[1];
+ memcpy (pp, put_path,
+ sizeof (struct GNUNET_PeerIdentity) * put_path_length);
+ memcpy (&pp[put_path_length], data, data_size);
+ GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail,
pending);
+ target_friend->pending_count++;
+ process_friend_queue (target_friend);
+}
+
+
+/**
+ *
+ * @param source_peer
+ * @param get_path
+ * @param get_path_length
+ * @param destination_peer
+ */
+void
+GDS_NEIGHBOURS_send_get_result (struct GNUNET_PeerIdentity *source_peer,
+ struct GNUNET_PeerIdentity *get_path,
+ unsigned int get_path_length,
+ struct GNUNET_PeerIdentity *destination_peer,
+ unsigned int current_path_index)
+{
+ /* Add get_result into pending message and send the data to target friend. */
+#if 0
+ struct PeerGetResultMessage *get_result;
+ struct P2PPendingMessage *pending;
+ size_t msize;
+
+ msize = (get_path_length * sizeof (struct GNUNET_PeerIdentity)) +
+ sizeof (struct PeerGetResultMessage);
+
+ if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ {
+ GNUNET_break (0);
+ return;
+ }
+
+#endif
+}
+
+
+/**
+ *
+ * @return
+ */
+static int
+handle_dht_p2p_get_result ()
+{
+ /* If you are the source, go back to the client file and there search for
+ the requesting client and send back the result. */
+ return GNUNET_YES;
+}
+
+
+
+/**
+ * Core handler for p2p put requests.
+ *
+ * @param cls closure
+ * @param peer sender of the request
+ * @param message message
+ * @param peer peer identity this notification is about
+ * @return #GNUNET_OK to keep the connection open,
+ * #GNUNET_SYSERR to close it (signal serious error)
+ */
+static int
+handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_MessageHeader *message)
+{
+ struct PeerPutMessage *put;
+ struct GNUNET_PeerIdentity *put_path;
+ enum GNUNET_DHT_RouteOption options;
+ enum current_destination_type current_dst_type;
+ struct GNUNET_PeerIdentity *current_destination;
+ struct GNUNET_PeerIdentity *source_peer;
+ struct GNUNET_PeerIdentity *next_hop;
+ struct GNUNET_HashCode test_key;
+ uint64_t key_value;
+ void *payload;
+ size_t payload_size;
+ size_t msize;
+ uint32_t putlen;
+
+ msize = ntohs (message->size);
+ if (msize < sizeof (struct PeerPutMessage))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_YES;
+ }
+
+ put = (struct PeerPutMessage *) message;
+ putlen = ntohl (put->put_path_length);
+ if ((msize <
+ sizeof (struct PeerPutMessage) +
+ putlen * sizeof (struct GNUNET_PeerIdentity)) ||
+ (putlen >
+ GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_YES;
+ }
+
+ put_path = (struct GNUNET_PeerIdentity *) &put[1];
+ payload = &put_path[putlen];
+ options = ntohl (put->options);
+ payload_size = msize - (sizeof (struct PeerPutMessage) +
+ putlen * sizeof (struct GNUNET_PeerIdentity));
+
+ /* FIXME: I don't understand what exactly are we doing here. */
+ switch (GNUNET_BLOCK_get_key
+ (GDS_block_context, ntohl (put->type), payload, payload_size,
+ &test_key))
+ {
+ case GNUNET_YES:
+ if (0 != memcmp (&test_key, &put->key, sizeof (struct GNUNET_HashCode)))
+ {
+ char *put_s = GNUNET_strdup (GNUNET_h2s_full (&put->key));
+ GNUNET_break_op (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "PUT with key `%s' for block with key %s\n",
+ put_s, GNUNET_h2s_full (&test_key));
+ GNUNET_free (put_s);
+ return GNUNET_YES;
+ }
+ break;
+ case GNUNET_NO:
+ GNUNET_break_op (0);
+ return GNUNET_YES;
+ case GNUNET_SYSERR:
+ /* cannot verify, good luck */
+ break;
+ }
+
+ /* FIXME: This part is also not clear to me.*/
+ if (ntohl (put->type) == GNUNET_BLOCK_TYPE_REGEX) /* FIXME: do for all tpyes
*/
+ {
+ switch (GNUNET_BLOCK_evaluate (GDS_block_context,
+ ntohl (put->type),
+ NULL, /* query */
+ NULL, 0, /* bloom filer */
+ NULL, 0, /* xquery */
+ payload, payload_size))
+ {
+ case GNUNET_BLOCK_EVALUATION_OK_MORE:
+ case GNUNET_BLOCK_EVALUATION_OK_LAST:
+ break;
+
+ case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
+ case GNUNET_BLOCK_EVALUATION_RESULT_INVALID:
+ case GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT:
+ case GNUNET_BLOCK_EVALUATION_REQUEST_VALID:
+ case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID:
+ case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
+ default:
+ GNUNET_break_op (0);
+ return GNUNET_OK;
+ }
+ }
+
+ struct GNUNET_PeerIdentity pp[putlen + 1];
+
+ /* extend 'put path' by sender */
+ if (0 != (options & GNUNET_DHT_RO_RECORD_ROUTE))
+ {
+ memcpy (pp, put_path, putlen * sizeof (struct GNUNET_PeerIdentity));
+ pp[putlen] = *peer;
+ putlen++;
+ }
+ else
+ putlen = 0;
+
+ /* Copy the fields of message, call find successor or gds_routing_search,
+ depending on the destination_type and if you are the final destination,
+ do a datache put or if option is. else call gds_neighbours_handle_get with
+ correct parameters. */
+ current_destination = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
+ memcpy (current_destination, &(put->current_destination), sizeof (struct
GNUNET_PeerIdentity));
+ current_dst_type = ntohl (put->current_destination_type);
+ memcpy (&key_value, &(put->key), sizeof (uint64_t));
+ source_peer = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
+ memcpy (source_peer, &(put->source_peer), sizeof (struct
GNUNET_PeerIdentity));
+
+ if (current_dst_type == FRIEND)
+ {
+ next_hop = find_successor (key_value, current_destination,
¤t_dst_type);
+ }
+ else if (current_dst_type == FINGER)
+ {
+ next_hop = GDS_ROUTING_search (source_peer, current_destination);
+ }
+
+ if (current_dst_type == MY_ID)
+ {
+ /* Here datacache_put*/
+ /* FIXME: Here depending on replication, call replicate_put() to do the
+ put operation on 'r' successors. */
+ GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (put->expiration_time),
+ &(put->key),putlen, pp, ntohl (put->type),
payload_size,
+ payload);
+ return GNUNET_YES;
+ }
+ else
+ {
+ /* here call gds_neighbours*/
+ GDS_NEIGHBOURS_handle_put (ntohl (put->type),ntohl (put->options),
+ ntohl (put->desired_replication_level),
+ GNUNET_TIME_absolute_ntoh
(put->expiration_time),
+ ntohl (put->hop_count),&put->key, putlen,
+ pp, payload, payload_size,
+ current_destination, ¤t_dst_type,
next_hop);
+ return GNUNET_YES;
+ }
+ return GNUNET_SYSERR;
+}
+
+
+/**
+ * FIXME: Handle expiration, options, block type, replication
+ * referring the old code.
+ * Core handler for p2p get requests.
+ *
+ * @param cls closure
+ * @param peer sender of the request
+ * @param message message
+ * @return #GNUNET_OK to keep the connection open,
+ * #GNUNET_SYSERR to close it (signal serious error)
+ */
+static int
+handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_MessageHeader *message)
+{
+ struct PeerGetMessage *get;
+ struct GNUNET_PeerIdentity *current_destination;
+ uint64_t key_value;
+ enum current_destination_type dest_type;
+ struct GNUNET_PeerIdentity *next_hop;
+ struct GNUNET_PeerIdentity *get_path;
+ size_t msize;
+ unsigned int get_length;
+
+ msize = ntohs (message->size);
+ if (msize < sizeof (struct PeerGetMessage))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_YES;
+ }
+
+ get = (struct PeerGetMessage *)message;
+ get_length = ntohl (get->get_path_length);
+ get_path = (struct GNUNET_PeerIdentity *)&get[1];
+
+ if ((msize <
+ sizeof (struct PeerGetMessage) +
+ get_length * sizeof (struct GNUNET_PeerIdentity)) ||
+ (get_length >
+ GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_YES;
+ }
+
+ get = (struct PeerGetMessage *) message;
+ current_destination = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
+ memcpy (current_destination, &(get->current_destination), sizeof (struct
GNUNET_PeerIdentity));
+ memcpy (&key_value, &(get->key), sizeof (uint64_t));
+ dest_type = ntohl (get->dest_type);
+
+ if (dest_type == FRIEND)
+ {
+ next_hop = find_successor (key_value, current_destination, &dest_type);
+ }
+ else if (dest_type == FINGER)
+ {
+ next_hop = GDS_ROUTING_search (&(get->source_peer), current_destination);
+ }
+
+ if (dest_type == MY_ID)
+ {
+ struct GNUNET_PeerIdentity *destination_peer;
+ int current_path_index;
+
+ /* Add yourself to the get path, increment the get length. */
+ destination_peer = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
+ memcpy (destination_peer, &(get->source_peer), sizeof (struct
GNUNET_PeerIdentity));
+ current_path_index = get_length - 2;
+
+ /* I am the final destination. Call GDS_NEIGHBOURS_send_get_result. */
+ GDS_NEIGHBOURS_send_get_result (&my_identity, get_path, get_length,
+ destination_peer, current_path_index);
+ return GNUNET_YES;
+ }
+ else
+ {
+ /* FIXME: Add your self to the get path and increment the get length. */
+
+ /* FIXME: Does it matter if the dest_type is friend or finger. */
+ GDS_NEIGHBOURS_handle_get (&(get->source_peer), get_path, get_length,
&(get->key),
+ next_hop, current_destination,&dest_type);
+
+ return GNUNET_YES;
+ }
+ return GNUNET_SYSERR;
+}
+
+
/**
* Handle a PeerTrailSetupMessage.
* @param cls closure
@@ -2434,6 +2815,7 @@
{
static struct GNUNET_CORE_MessageHandler core_handlers[] = {
{&handle_dht_p2p_get, GNUNET_MESSAGE_TYPE_DHT_P2P_GET, 0},
+ {&handle_dht_p2p_get_result, GNUNET_MESSAGE_TYPE_DHT_P2P_GET_RESULT, 0},
{&handle_dht_p2p_put, GNUNET_MESSAGE_TYPE_DHT_P2P_PUT, 0},
{&handle_dht_p2p_trail_setup, GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP, 0},
{&handle_dht_p2p_trail_setup_result,
GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP_RESULT, 0},
Modified: gnunet/src/dht/gnunet-service-xdht_neighbours.h
===================================================================
--- gnunet/src/dht/gnunet-service-xdht_neighbours.h 2014-03-28 08:41:34 UTC
(rev 32818)
+++ gnunet/src/dht/gnunet-service-xdht_neighbours.h 2014-03-28 10:24:39 UTC
(rev 32819)
@@ -32,6 +32,19 @@
#include "gnunet_dht_service.h"
/**
+ * FIXME: Change the comment to explain about usage of this in find successor.
+ * Field in trail setup message to understand if the message is sent to an
+ * intermediate finger, friend or me.
+ */
+enum current_destination_type
+{
+ FRIEND ,
+ FINGER ,
+ MY_ID ,
+ VALUE
+};
+
+/**
* Perform a PUT operation. Forwards the given request to other
* peers. Does not store the data locally. Does not give the
* data to local clients. May do nothing if this is the only
@@ -40,15 +53,14 @@
*
* @param type type of the block
* @param options routing options
- * @param desired_replication_level desired replication level
+ * @param desired_replication_level desired replication count
* @param expiration_time when does the content expire
* @param hop_count how many hops has this message traversed so far
- * @param bf Bloom filter of peers this PUT has already traversed
* @param key key for the content
- * @param put_path_length number of entries in put_path
+ * @param put_path_length number of entries in @a put_path
* @param put_path peers this request has traversed so far (if tracked)
* @param data payload to store
- * @param data_size number of bytes in data
+ * @param data_size number of bytes in @a data
*/
void
GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
@@ -56,41 +68,46 @@
uint32_t desired_replication_level,
struct GNUNET_TIME_Absolute expiration_time,
uint32_t hop_count,
- struct GNUNET_CONTAINER_BloomFilter *bf,
- const struct GNUNET_HashCode * key,
+ struct GNUNET_HashCode * key,
unsigned int put_path_length,
struct GNUNET_PeerIdentity *put_path,
- const void *data, size_t data_size);
+ const void *data, size_t data_size,
+ struct GNUNET_PeerIdentity *current_destination,
+ enum current_destination_type *dest_type,
+ struct GNUNET_PeerIdentity *target_peer_id);
/**
- * Perform a GET operation. Forwards the given request to other
- * peers. Does not lookup the key locally. May do nothing if this is
- * the only peer in the network (or if we are the closest peer in the
- * network).
- *
- * @param type type of the block
- * @param options routing options
- * @param desired_replication_level desired replication count
- * @param hop_count how many hops did this request traverse so far?
- * @param key key for the content
- * @param xquery extended query
- * @param xquery_size number of bytes in xquery
- * @param reply_bf bloomfilter to filter duplicates
- * @param reply_bf_mutator mutator for reply_bf
- * @param peer_bf filter for peers not to select (again, updated)
+ *
+ * @param source_peer
+ * @param get_path
+ * @param get_path_length
+ * @param key
*/
void
-GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
- enum GNUNET_DHT_RouteOption options,
- uint32_t desired_replication_level,
- uint32_t hop_count, const struct GNUNET_HashCode *
key,
- const void *xquery, size_t xquery_size,
- const struct GNUNET_CONTAINER_BloomFilter *reply_bf,
- uint32_t reply_bf_mutator,
- struct GNUNET_CONTAINER_BloomFilter *peer_bf);
+GDS_NEIGHBOURS_handle_get (struct GNUNET_PeerIdentity *source_peer,
+ struct GNUNET_PeerIdentity *get_path,
+ unsigned int get_path_length,
+ struct GNUNET_HashCode *key,
+ struct GNUNET_PeerIdentity *target_peer,
+ struct GNUNET_PeerIdentity *current_destination,
+ enum current_destination_type *type);
+/**
+ *
+ * @param source_peer
+ * @param get_path
+ * @param get_path_length
+ * @param destination_peer
+ */
+void
+GDS_NEIGHBOURS_send_get_result (struct GNUNET_PeerIdentity *source_peer,
+ struct GNUNET_PeerIdentity *get_path,
+ unsigned int get_path_length,
+ struct GNUNET_PeerIdentity *destination_peer,
+ unsigned int current_path_index);
+
/**
* Initialize neighbours subsystem.
*
Modified: gnunet/src/dht/gnunet-service-xdht_routing.c
===================================================================
--- gnunet/src/dht/gnunet-service-xdht_routing.c 2014-03-28 08:41:34 UTC
(rev 32818)
+++ gnunet/src/dht/gnunet-service-xdht_routing.c 2014-03-28 10:24:39 UTC
(rev 32819)
@@ -28,15 +28,7 @@
#include "gnunet-service-xdht_routing.h"
#include "gnunet-service-xdht.h"
-/* FIXME
- * 1. We need field to understand which routing table is for which peer.
- * 2. Better function names and variable names.
- * 3. Use destination peer id as key for routing table.
- * 4. What does GDS stands for?
- *
- */
-
/**
* Number of requests we track at most (for routing replies).
*/
@@ -109,7 +101,7 @@
}
-/**
+/**FIXME: Test if its correct or not.
* Find the next hop to send packet to .
* @return next hop peer id
*/
@@ -153,7 +145,7 @@
const struct GNUNET_PeerIdentity *get_path,
const void *data, size_t data_size)
{
-
+ return;
}
Modified: gnunet/src/include/gnunet_protocols.h
===================================================================
--- gnunet/src/include/gnunet_protocols.h 2014-03-28 08:41:34 UTC (rev
32818)
+++ gnunet/src/include/gnunet_protocols.h 2014-03-28 10:24:39 UTC (rev
32819)
@@ -630,6 +630,11 @@
* Message which contains the immediate predecessor of requested successor
*/
#define GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR_RESULT 161
+
+/**
+ * Message which contains the get result.
+ */
+#define GNUNET_MESSAGE_TYPE_DHT_P2P_GET_RESULT 162
/*******************************************************************************
* HOSTLIST message types
******************************************************************************/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32819 - in gnunet/src: dht include,
gnunet <=