/*
This file is part of GNUnet.
- Copyright (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2009, 2010, 2011 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
- * @file dht/gnunet-service-dht_clients.c
+ * @file dht/gnunet-service-wdht_clients.c
* @brief GNUnet DHT service's client management code
* @author Christian Grothoff
* @author Nathan Evans
size_t xquery_size;
/**
- * Number of entries in 'seen_replies'.
+ * Number of entries in @e seen_replies.
*/
unsigned int seen_replies_count;
/**
- * Callback called as a result of issuing a GNUNET_SERVER_notify_transmit_ready
+ * 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.
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);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitting %u bytes to client %p\n",
+ (unsigned int) 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);
+ 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;
}
/**
- * Closure for 'forward_reply'
+ * Closure for #forward_reply()
*/
struct ForwardReplyContext
{
size_t data_size;
/**
- * Do we need to copy 'pm' because it was already used?
+ * Do we need to copy @e pm because it was already used?
*/
int do_copy;
* each of the matching clients. With some tricky recycling
* of the buffer.
*
- * @param cls the 'struct ForwardReplyContext'
+ * @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
+ * @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)
+forward_reply (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct ForwardReplyContext *frc = cls;
struct ClientQueryRecord *record = value;
}
}
+
/**
* Check if some client is monitoring GET messages and notify
* them in that case.
uint32_t desired_replication_level,
unsigned int path_length,
const struct GNUNET_PeerIdentity *path,
- const struct GNUNET_HashCode * key)
+ const struct GNUNET_HashCode *key)
{
struct ClientMonitorRecord *m;
struct ClientList **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 options options, for instance RecordRoute, DemultiplexEverywhere.
+ * @param type type of data in the request.
+ * @param hop_count hop count so far.
+ * @param path_length number of entries in @a 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.
+ * @param desired_replication_level desired replication level.
+ * @param exp expiration time of the data.
+ * @param key key under which @a data is to be stored.
+ * @param data pointer to the data carried.
+ * @param size number of bytes in @a data.
*/
void
GDS_CLIENTS_process_put (uint32_t options,
unsigned int path_length,
const struct GNUNET_PeerIdentity *path,
struct GNUNET_TIME_Absolute exp,
- const struct GNUNET_HashCode * key,
+ const struct GNUNET_HashCode *key,
const void *data,
size_t size)
{
* itself (unless the heap is empty).
*
* @param cls unused
- * @param tc scheduler context
*/
static void
-transmit_next_request_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+transmit_next_request_task (void *cls)
{
struct ClientQueryRecord *cqr;
struct GNUNET_TIME_Relative delay;
retry_task = NULL;
- if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
- return;
while (NULL != (cqr = GNUNET_CONTAINER_heap_remove_root (retry_heap)))
{
cqr->hnode = NULL;
* @param message the actual message received
*/
static void
-handle_dht_local_put (void *cls, struct GNUNET_SERVER_Client *client,
+handle_dht_local_put (void *cls,
+ struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct GNUNET_DHT_ClientPutMessage *put_msg;
* @param message the actual message received
*/
static void
-handle_dht_local_get (void *cls, struct GNUNET_SERVER_Client *client,
+handle_dht_local_get (void *cls,
+ struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct GNUNET_DHT_ClientGetMessage *get;
/**
- * Closure for 'find_by_unique_id'.
+ * Closure for #find_by_unique_id().
*/
struct FindByUniqueIdContext
{
*/
struct ClientQueryRecord *cqr;
+ /**
+ * Which ID are we looking for?
+ */
uint64_t unique_id;
};
*
* @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)
+ * @param value the `struct ClientQueryRecord`
+ * @return #GNUNET_YES to continue iteration (result not yet found)
*/
static int
find_by_unique_id (void *cls,
* @param message the actual message received
*/
static void
-handle_dht_local_get_result_seen (void *cls, struct GNUNET_SERVER_Client *client,
+handle_dht_local_get_result_seen (void *cls,
+ struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct GNUNET_DHT_ClientGetResultSeenMessage *seen;
/**
- * Closure for 'remove_by_unique_id'.
+ * Closure for #remove_by_unique_id().
*/
struct RemoveByUniqueIdContext
{
* @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)
+ * @return #GNUNET_YES (we should continue to iterate)
*/
static int
-remove_by_unique_id (void *cls, const struct GNUNET_HashCode * key, void *value)
+remove_by_unique_id (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
const struct RemoveByUniqueIdContext *ctx = cls;
struct ClientQueryRecord *record = value;
*
*/
static void
-handle_dht_local_get_stop (void *cls, struct GNUNET_SERVER_Client *client,
+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 =
*
*/
static void
-handle_dht_local_monitor (void *cls, struct GNUNET_SERVER_Client *client,
+handle_dht_local_monitor (void *cls,
+ struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
struct ClientMonitorRecord *r;
* @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,
+handle_dht_local_monitor_stop (void *cls,
+ struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
struct ClientMonitorRecord *r;
}
r = r->next;
}
-
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
-#if ENABLE_MALICIOUS
-/**
- * Handler for act malicious message.
- *
- * @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_act_malicious (void *cls, struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
-{
- const struct GNUNET_DHT_ActMaliciousMessage *msg;
- struct PendingMessage *pm;
- struct GNUNET_DHT_ClientActMaliciousConfirmationMessage *conf;
- unsigned int malicious_action;
-
- msg = (const struct GNUNET_DHT_ActMaliciousMessage *)message;
- malicious_action = msg->action;
-
- if(GNUNET_OK == GDS_NEIGHBOURS_act_malicious (malicious_action))
- {
- pm = GNUNET_malloc (sizeof (struct PendingMessage) +
- sizeof (struct GNUNET_DHT_ClientActMaliciousConfirmationMessage));
- conf = (struct GNUNET_DHT_ClientActMaliciousConfirmationMessage *) &pm[1];
- conf->header.size = htons (sizeof (struct GNUNET_DHT_ClientActMaliciousConfirmationMessage));
- conf->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_CLIENT_ACT_MALICIOUS_OK);
- pm->msg = &conf->header;
- add_pending_message (find_active_client (client), pm);
- GNUNET_SERVER_receive_done (client, GNUNET_OK);
- }
-}
-#endif
-
-
/**
* Functions with this signature are called whenever a client
* is disconnected on the network level.
}
-
/**
* Initialize client subsystem.
*
sizeof (struct GNUNET_DHT_MonitorStartStopMessage)},
{&handle_dht_local_get_result_seen, NULL,
GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN, 0},
- #if ENABLE_MALICIOUS
- {&handle_dht_act_malicious, NULL,
- GNUNET_MESSAGE_TYPE_DHT_ACT_MALICIOUS,
- sizeof (struct GNUNET_DHT_ActMaliciousMessage)},
- #endif
{NULL, NULL, 0, 0}
};
forward_map = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_NO);
}
}
-/* end of gnunet-service-dht_clients.c */
+/* end of gnunet-service-wdht_clients.c */