if (DEFAULT_FISHEYE_DEPTH - 1 == neighbor->consensus_insertion_distance)
{
/* we have added all elements to the set, run the operation */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Finished building my SET, committing\n");
GNUNET_SET_commit (neighbor->set_op,
- neighbor->my_set);
+ neighbor->my_set);
GNUNET_SET_destroy (neighbor->my_set);
neighbor->my_set = NULL;
return;
(consensi[neighbor->consensus_insertion_distance].array_length < neighbor->consensus_insertion_offset) &&
(NULL == consensi[neighbor->consensus_insertion_distance].targets[neighbor->consensus_insertion_offset]) )
neighbor->consensus_insertion_offset++;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding element to SET\n");
GNUNET_SET_add_element (neighbor->my_set,
&element,
&build_set, neighbor);
struct Route *route;
struct GNUNET_HashCode session_id;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Direct connection to %s established, routing table exchange begins.\n",
+ GNUNET_i2s (&neighbor->peer));
GNUNET_STATISTICS_update (stats,
"# peers connected (1-hop)",
1, GNUNET_NO);
&session_id, sizeof (session_id),
NULL, 0);
if (1 == GNUNET_CRYPTO_hash_cmp (&neighbor->peer.hashPubKey,
- &my_identity.hashPubKey))
+ &my_identity.hashPubKey))
+ {
neighbor->initiate_task = GNUNET_SCHEDULER_add_now (&initiate_set_union,
- neighbor);
+ neighbor);
+ }
else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Starting SET listen operation\n");
neighbor->listen_handle = GNUNET_SET_listen (cfg,
GNUNET_SET_OPERATION_UNION,
&neighbor->real_session_id,
&listen_set_union,
neighbor);
+ }
}
* @param peer peer identity this notification is about
*/
static void
-handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
+handle_core_connect (void *cls,
+ const struct GNUNET_PeerIdentity *peer)
{
struct DirectNeighbor *neighbor;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Core connected to %s (distance unknown)\n",
GNUNET_i2s (peer));
- neighbor = GNUNET_malloc (sizeof (struct DirectNeighbor));
+ neighbor = GNUNET_new (struct DirectNeighbor);
neighbor->peer = *peer;
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_put (direct_neighbors,
* @return GNUNET_YES to continue iteration, GNUNET_NO to stop
*/
static int
-check_possible_route (void *cls, const struct GNUNET_HashCode * key, void *value)
+check_possible_route (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct DirectNeighbor *neighbor = cls;
struct Target *target = value;
struct Route *route;
route = GNUNET_CONTAINER_multihashmap_get (all_routes,
- key);
+ key);
if (NULL != route)
{
if (ntohl (route->target.distance) > ntohl (target->distance) + 1)
}
return GNUNET_YES; /* got a route to this target already */
}
- route = GNUNET_malloc (sizeof (struct Route));
+ route = GNUNET_new (struct Route);
route->next_hop = neighbor;
route->target.distance = htonl (ntohl (target->distance) + 1);
route->target.peer = target->peer;
* @return GNUNET_YES to continue iteration
*/
static int
-refresh_routes (void *cls, const struct GNUNET_HashCode * key, void *value)
+refresh_routes (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct DirectNeighbor *neighbor = value;
* @return GNUNET_YES to continue iteration, GNUNET_NO to stop
*/
static int
-cull_routes (void *cls, const struct GNUNET_HashCode * key, void *value)
+cull_routes (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct DirectNeighbor *neighbor = cls;
struct Route *route = value;
handle_direct_connect (neighbor);
return;
}
- neighbor = GNUNET_malloc (sizeof (struct DirectNeighbor));
+ neighbor = GNUNET_new (struct DirectNeighbor);
neighbor->peer = address->peer;
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_put (direct_neighbors,
*/
static int
check_target_added (void *cls,
- const struct GNUNET_HashCode *key,
- void *value)
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct DirectNeighbor *neighbor = cls;
struct Target *target = value;
"Discovered new route to %s using %u hops\n",
GNUNET_i2s (&target->peer),
(unsigned int) (ntohl (target->distance) + 1));
- current_route = GNUNET_malloc (sizeof (struct Route));
+ current_route = GNUNET_new (struct Route);
current_route->next_hop = neighbor;
current_route->target.peer = target->peer;
current_route->target.distance = htonl (ntohl (target->distance) + 1);
struct DirectNeighbor *neighbor = cls;
struct Target *target;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got SET union result: %d\n",
+ status);
switch (status)
{
case GNUNET_SET_STATUS_OK:
GNUNET_break_op (0);
return;
}
- target = GNUNET_malloc (sizeof (struct Target));
+ target = GNUNET_new (struct Target);
memcpy (target, element->data, sizeof (struct Target));
if (GNUNET_YES !=
GNUNET_CONTAINER_multihashmap_put (neighbor->neighbor_table_consensus,
{
struct DirectNeighbor *neighbor = cls;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Initiating SET union\n");
neighbor->initiate_task = GNUNET_SCHEDULER_NO_TASK;
neighbor->my_set = GNUNET_SET_create (cfg,
GNUNET_SET_OPERATION_UNION);
const struct GNUNET_MessageHeader *payload;
struct Route *route;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Handling DV message\n");
if (ntohs (message->size) < sizeof (struct RouteMessage) + sizeof (struct GNUNET_MessageHeader))
{
GNUNET_break_op (0);
1, GNUNET_NO);
return GNUNET_OK;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Forwarding message to %s\n",
+ GNUNET_i2s (&rm->target));
forward_payload (route->next_hop,
ntohl (route->target.distance),
0,
#include "dv.h"
+#define LOG(kind,...) GNUNET_log_from (kind, "transport-dv",__VA_ARGS__)
+
+
/**
* Encapsulation of all of the state of the plugin.
*/
notify_distance_change (session);
return; /* nothing to do */
}
- session = GNUNET_malloc (sizeof (struct Session));
+ session = GNUNET_new (struct Session);
session->sender = *peer;
session->distance = distance;
GNUNET_assert (GNUNET_YES ==
memcpy (&box[1], msgbuf, msgbuf_size);
msg = box;
}
- pr = GNUNET_malloc (sizeof (struct PendingRequest));
+ pr = GNUNET_new (struct PendingRequest);
pr->transmit_cont = cont;
pr->transmit_cont_cls = cont_cls;
pr->session = session;
/**
* Entry point for the plugin.
+ *
+ * @param cls closure with the plugin environment
+ * @return plugin API
*/
void *
libgnunet_plugin_transport_dv_init (void *cls)
struct GNUNET_TRANSPORT_PluginFunctions *api;
struct Plugin *plugin;
- plugin = GNUNET_malloc (sizeof (struct Plugin));
+ plugin = GNUNET_new (struct Plugin);
plugin->env = env;
plugin->sessions = GNUNET_CONTAINER_multihashmap_create (1024 * 8, GNUNET_YES);
plugin->mst = GNUNET_SERVER_mst_create (&unbox_cb,
GNUNET_free (plugin);
return NULL;
}
- api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
+ api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions);
api->cls = plugin;
api->send = &dv_plugin_send;
api->disconnect = &dv_plugin_disconnect;
/**
* Exit point from the plugin.
+ *
+ * @param cls plugin API
+ * @return NULL
*/
void *
libgnunet_plugin_transport_dv_done (void *cls)