/*
This file is part of GNUnet.
- Copyright (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2009, 2010, 2011, 2016 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.
*/
/**
/**
* Actual message to be sent, allocated at the end of the struct:
* // msg = (cast) &pm[1];
- * // memcpy (&pm[1], data, len);
+ * // GNUNET_memcpy (&pm[1], data, len);
*/
const struct GNUNET_MessageHeader *msg;
{
GNUNET_CONTAINER_DLL_remove (client->pending_head, client->pending_tail,
reply);
- memcpy (&cbuf[off], reply->msg, msize);
+ GNUNET_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;
}
/* 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,
+ GNUNET_memcpy (pm, frc->pm,
sizeof (struct PendingMessage) + ntohs (frc->pm->msg->size));
pm->next = pm->prev = NULL;
pm->msg = (struct GNUNET_MessageHeader *) &pm[1];
_("Could not pass reply to client, message too big!\n"));
return;
}
- DEBUG("reply FOR DATA_SIZE = %lu\n",msize);
+ DEBUG ("reply FOR DATA_SIZE = %u\n",
+ (unsigned int) msize);
pm = GNUNET_malloc (msize + sizeof (struct PendingMessage));
reply = (struct GNUNET_DHT_ClientResultMessage *) &pm[1];
pm->msg = &reply->header;
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);
+ GNUNET_memcpy (paths,
+ put_path,
+ sizeof (struct GNUNET_PeerIdentity) * put_path_length);
+ GNUNET_memcpy (&paths[put_path_length],
+ get_path,
+ sizeof (struct GNUNET_PeerIdentity) * get_path_length);
+ GNUNET_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,
+ GNUNET_CONTAINER_multihashmap_get_multiple (forward_map,
+ key,
+ &forward_reply,
&frc);
if (GNUNET_NO == frc.do_copy)
{
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));
+ GNUNET_memcpy (&mmsg->key, key, sizeof (struct GNUNET_HashCode));
msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1];
if (path_length > 0)
- memcpy (msg_path, path,
+ GNUNET_memcpy (msg_path, path,
path_length * sizeof (struct GNUNET_PeerIdentity));
add_pending_message (m->client, pm);
}
msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1];
if (path_length > 0)
{
- memcpy (msg_path, path,
+ GNUNET_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));
+ GNUNET_memcpy (&mmsg->key, key, sizeof (struct GNUNET_HashCode));
if (size > 0)
- memcpy (&msg_path[path_length], data, size);
+ GNUNET_memcpy (&msg_path[path_length], data, size);
add_pending_message (m->client, pm);
}
}
* 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;
cqr->key = get->key;
cqr->client = find_active_client (client);
cqr->xquery = (void *) &cqr[1];
- memcpy (&cqr[1], xquery, xquery_size);
+ GNUNET_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 ();
GNUNET_array_grow (cqr->seen_replies,
cqr->seen_replies_count,
cqr->seen_replies_count + hash_count);
- memcpy (&cqr->seen_replies[old_count],
+ GNUNET_memcpy (&cqr->seen_replies[old_count],
hc,
sizeof (struct GNUNET_HashCode) * hash_count);
}
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));
+ GNUNET_h2s (&dht_stop_msg->key),
+ client);
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,
else
{
r->key = GNUNET_new (struct GNUNET_HashCode);
- memcpy (r->key, &msg->key, sizeof (struct GNUNET_HashCode));
+ GNUNET_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);
}
-#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.
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);