sizeof (struct GNUNET_MESH_ConnectionBroken)},
{&GMC_handle_destroy, GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY,
sizeof (struct GNUNET_MESH_ConnectionDestroy)},
- {&GMC_handle_keepalive, GNUNET_MESSAGE_TYPE_MESH_FWD_KEEPALIVE,
- sizeof (struct GNUNET_MESH_ConnectionKeepAlive)},
- {&GMC_handle_keepalive, GNUNET_MESSAGE_TYPE_MESH_BCK_KEEPALIVE,
+ {&GMC_handle_keepalive, GNUNET_MESSAGE_TYPE_MESH_KEEPALIVE,
sizeof (struct GNUNET_MESH_ConnectionKeepAlive)},
{&GMC_handle_ack, GNUNET_MESSAGE_TYPE_MESH_ACK,
sizeof (struct GNUNET_MESH_ACK)},
size_t size_needed;
int i;
+ if (NULL == p)
+ return 0;
+
LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending CONNECTION CREATE...\n");
size_needed =
sizeof (struct GNUNET_MESH_ConnectionCreate) +
/**
- * Choose the best path towards a peer considering the tunnel properties.
+ * Choose the best (yet unused) path towards a peer,
+ * considering the tunnel properties.
*
* @param peer The destination peer.
*
/* Fill buf */
switch (queue->type)
{
- case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY:
case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY:
case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN:
+ case GNUNET_MESSAGE_TYPE_MESH_KEEPALIVE:
case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
case GNUNET_MESSAGE_TYPE_MESH_KX:
case GNUNET_MESSAGE_TYPE_MESH_ACK:
case GNUNET_MESSAGE_TYPE_MESH_POLL:
LOG (GNUNET_ERROR_TYPE_DEBUG,
"* raw: %s\n",
- GNUNET_MESH_DEBUG_M2S (queue->type));
+ GM_m2s (queue->type));
data_size = send_core_data_raw (queue->cls, size, buf);
break;
case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE:
{
LOG (GNUNET_ERROR_TYPE_WARNING,
"Dropping message of type %s\n",
- GNUNET_MESH_DEBUG_M2S (queue->type));
+ GM_m2s (queue->type));
data_size = 0;
}
if (GNUNET_YES == clear_cls)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "# queue destroy type %s\n",
- GNUNET_MESH_DEBUG_M2S (queue->type));
+ GM_m2s (queue->type));
switch (queue->type)
{
case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY:
- case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY:
LOG (GNUNET_ERROR_TYPE_INFO, "destroying a DESTROY message\n");
/* fall through */
- case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
- case GNUNET_MESSAGE_TYPE_MESH_ACK:
- case GNUNET_MESSAGE_TYPE_MESH_POLL:
case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK:
case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE:
case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN:
case GNUNET_MESSAGE_TYPE_MESH_KX:
- LOG (GNUNET_ERROR_TYPE_DEBUG, "# prebuilt message\n");;
+ case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
+ case GNUNET_MESSAGE_TYPE_MESH_ACK:
+ case GNUNET_MESSAGE_TYPE_MESH_POLL:
GNUNET_free_non_null (queue->cls);
break;
default:
GNUNET_break (0);
LOG (GNUNET_ERROR_TYPE_ERROR, "# type %s unknown!\n",
- GNUNET_MESH_DEBUG_M2S (queue->type));
+ GM_m2s (queue->type));
}
}
GNUNET_CONTAINER_DLL_remove (peer->queue_head, peer->queue_tail, queue);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"queue add %s %s towards %s (size %u) on c %p (%s)\n",
- fwd ? "FWD" : "BCK", GNUNET_MESH_DEBUG_M2S (type), GMP_2s(peer),
+ GM_f2s (fwd), GM_m2s (type), GMP_2s(peer),
size, c, GMC_2s (c));
GNUNET_assert (NULL != c);
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"GMP_cancel_queue %s\n",
- GNUNET_MESH_DEBUG_M2S (q->type));
+ GM_m2s (q->type));
GMP_queue_destroy (q, GNUNET_YES);
/* Get next from prev, q->next might be already freed:
struct MeshConnection *c;
int rerun_search;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "peer_connect towards %s\n",
- GMP_2s (peer));
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "peer_connect towards %s\n", GMP_2s (peer));
t = peer->tunnel;
c = NULL;
rerun_search = GNUNET_NO;
* path.
*
* Re-running the DHT GET should give core time to callback.
+ *
+ * GMT_use_path -> GMC_new -> register_neighbors takes care of
+ * updating statistics about this issue.
*/
- GNUNET_break(0);
- rerun_search = GNUNET_YES;
+ rerun_search = GNUNET_YES;
}
else
{
}
+/**
+ * Remove any path to the peer that has the extact same peers as the one given.
+ *
+ * @param peer Peer to remove the path from.
+ * @param path Path to remove. Is always destroyed .
+ */
+void
+GMP_remove_path (struct MeshPeer *peer, struct MeshPeerPath *path)
+{
+ struct MeshPeerPath *iter;
+ struct MeshPeerPath *next;
+
+ GNUNET_assert (myid == path->peers[0]);
+ GNUNET_assert (peer->id == path->peers[path->length - 1]);
+
+ for (iter = peer->path_head; NULL != iter; iter = next)
+ {
+ next = iter->next;
+ if (0 == memcmp (path->peers, iter->peers,
+ sizeof (GNUNET_PEER_Id) * path->length))
+ {
+ GNUNET_CONTAINER_DLL_remove (peer->path_head, peer->path_tail, iter);
+ path_destroy (iter);
+ if (path == iter)
+ return;
+ }
+ }
+ path_destroy (path);
+}
+
+
/**
* Remove a connection from a neighboring peer.
*
{
if (NULL == peer || NULL == peer->connections)
{
- GNUNET_break (0);
- LOG (GNUNET_ERROR_TYPE_WARNING,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Peer %s is not a neighbor!\n",
GMP_2s (peer));
return GNUNET_SYSERR;
struct MeshTunnel3 *
GMP_get_tunnel (const struct MeshPeer *peer)
{
+ GNUNET_assert (NULL != peer->tunnel);
return peer->tunnel;
}