*/
static MESH_TunnelNumber next_tid;
+/**
+ * Tunnel ID for the next incoming tunnel (local tunnel number)
+ */
+static MESH_TunnelNumber next_local_tid;
+
/**
* All application types provided by this peer
*/
pi = (struct GNUNET_PeerIdentity *) &msg[1];
t = tunnel_get (pi, tid);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "MESH: path as for tunnel %s [%X].\n",
+ "MESH: path is for tunnel %s [%X].\n",
GNUNET_i2s(pi),
tid);
if (NULL == t)
t->id.oid = GNUNET_PEER_intern (pi);
t->id.tid = tid;
t->peers = GNUNET_CONTAINER_multihashmap_create (32);
+ t->local_tid = next_local_tid++;
+ next_local_tid |= GNUNET_MESH_LOCAL_TUNNEL_ID_SERV;
GNUNET_CRYPTO_hash (&t->id, sizeof (struct MESH_TunnelID), &hash);
if (GNUNET_OK !=
if (own_pos == size - 1)
{
/* It is for us! Send ack. */
+ struct GNUNET_MESH_TunnelNotification cmsg;
struct MeshDataDescriptor *info;
unsigned int j;
GNUNET_TIME_UNIT_FOREVER_REL, peer,
sizeof (struct GNUNET_MESH_PathACK),
&send_core_path_ack, info);
+ cmsg.header.size = htons(sizeof(cmsg));
+ cmsg.header.type = htons(GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE);
+ GNUNET_PEER_resolve(t->id.oid, &cmsg.peer);
+ cmsg.tunnel_id = htonl(t->local_tid);
+ GNUNET_SERVER_notification_context_broadcast(nc, &cmsg.header, GNUNET_NO);
}
else
{
path = path_new (2);
path->peers[0] = myid;
path->peers[1] = peer_info->id;
+ GNUNET_PEER_change_rc(myid, 1);
+ GNUNET_PEER_change_rc(peer_info->id, 1);
path_add_to_peer (peer_info, path);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer disconnected\n");
pi = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey);
- if (!pi)
+ if (NULL == pi)
{
GNUNET_break (0);
return;
struct MeshPathInfo *path_info;
GNUNET_CORE_notify_transmit_ready_cancel (pi->core_transmit[i]);
/* TODO: notify that tranmission has failed */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: data at %u\n", i);
switch (pi->types[i])
{
case GNUNET_MESSAGE_TYPE_MESH_MULTICAST:
case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: type payload\n");
dd = pi->infos[i];
if (0 == --(*dd->copies))
{
}
break;
case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: type create path\n");
path_info = pi->infos[i];
path_destroy(path_info->path);
break;
// }
next_tid = 0;
+ next_local_tid = GNUNET_MESH_LOCAL_TUNNEL_ID_SERV;
tunnels = GNUNET_CONTAINER_multihashmap_create (32);
peers = GNUNET_CONTAINER_multihashmap_create (32);