*/
static void
send_prebuilt_message (const struct GNUNET_MessageHeader *message,
- const struct GNUNET_PeerIdentity *peer,
+ GNUNET_PEER_Id peer,
struct MeshTunnel *t)
{
struct MeshTransmissionDescriptor *info;
+ struct GNUNET_PeerIdentity id;
struct MeshPeerInfo *neighbor;
struct MeshPeerPath *p;
size_t size;
// GNUNET_TRANSPORT_try_connect(); FIXME use?
+ if (0 == peer)
+ return;
+
size = ntohs (message->size);
info = GNUNET_malloc (sizeof (struct MeshTransmissionDescriptor));
info->data = GNUNET_malloc (size);
to->pid = htonl(t->bck_pid);
}
info->data_len = size;
- neighbor = peer_get (peer);
+ GNUNET_PEER_resolve (peer, &id);
+ neighbor = peer_get (&id);
for (p = neighbor->path_head; NULL != p; p = p->next)
{
if (2 >= p->length)
#if MESH_DEBUG
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
" %s IS NOT DIRECTLY CONNECTED\n",
- GNUNET_i2s(peer));
+ GNUNET_i2s(&id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
" PATHS TO %s:\n",
- GNUNET_i2s(peer));
+ GNUNET_i2s(&id));
for (p = neighbor->path_head; NULL != p; p = p->next)
{
struct GNUNET_PeerIdentity debug_id;
GNUNET_break (0); // FIXME sometimes fails (testing disconnect?)
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
" no direct connection to %s\n",
- GNUNET_i2s (peer));
+ GNUNET_i2s (&id));
GNUNET_free (info->data);
GNUNET_free (info);
return;
* @param ack Value of the ACK.
*/
static void
-send_ack (struct MeshTunnel *t, struct GNUNET_PeerIdentity *peer, uint32_t ack)
+send_ack (struct MeshTunnel *t, GNUNET_PEER_Id peer, uint32_t ack)
{
struct GNUNET_MESH_ACK msg;
static void
tunnel_send_fwd_ack (struct MeshTunnel *t, uint16_t type)
{
- struct GNUNET_PeerIdentity id;
uint32_t ack;
if (NULL != t->owner)
}
t->last_fwd_ack = ack;
- GNUNET_PEER_resolve (t->prev_hop, &id);
- send_ack (t, &id, ack);
+ send_ack (t, t->prev_hop, ack);
debug_fwd_ack++;
t->force_ack = GNUNET_NO;
}
*/
static void
tunnel_send_child_bck_ack (struct MeshTunnel *t,
- GNUNET_PEER_Id id)
+ GNUNET_PEER_Id peer)
{
- struct GNUNET_PeerIdentity peer;
uint32_t ack = 0; // FIXME
- GNUNET_PEER_resolve (id, &peer);
// ack = cinfo->bck_pid + t->bck_queue_max - t->bck_queue_n;
//
// if (cinfo->bck_ack == ack && GNUNET_NO == t->force_ack)
// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
// " Sending BCK ACK %u (last sent: %u)\n",
// ack, cinfo->bck_ack);
- send_ack (t, &peer, ack);
+ send_ack (t, peer, ack);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " child: %u\n", t->next_hop);
GNUNET_PEER_resolve (t->next_hop, &id);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- " sending back to %s\n",
+ " sending forward to %s\n",
GNUNET_i2s (&id));
- send_prebuilt_message (&msg.header, &id, t);
+ send_prebuilt_message (&msg.header, t->next_hop, t);
}
if (0 != t->prev_hop)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
" sending back to %s\n",
GNUNET_i2s (&id));
- send_prebuilt_message (&msg.header, &id, t);
+ send_prebuilt_message (&msg.header, t->prev_hop, t);
}
}
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Own position: %u\n", own_pos);
if (own_pos < path->length - 1)
- send_prebuilt_message (message, &pi[own_pos + 1], t);
+ send_prebuilt_message (message, path->peers[own_pos + 1], t);
else
send_client_tunnel_disconnect(t, NULL);
const struct GNUNET_MessageHeader *message)
{
struct GNUNET_MESH_Unicast *msg;
- struct GNUNET_PeerIdentity neighbor;
struct MeshTunnel *t;
GNUNET_PEER_Id dest_id;
uint32_t pid;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
" not for us, retransmitting...\n");
- GNUNET_PEER_resolve (t->next_hop, &neighbor);
-
/* cinfo->fwd_pid = pid; FIXME
if (GNUNET_YES == t->nobuffer &&
GNUNET_break_op (0);
return GNUNET_OK;
}*/
- send_prebuilt_message (message, &neighbor, t);
+ send_prebuilt_message (message, t->next_hop, t);
GNUNET_STATISTICS_update (stats, "# unicast forwarded", 1, GNUNET_NO);
return GNUNET_OK;
}
const struct GNUNET_MessageHeader *message)
{
struct GNUNET_MESH_ToOrigin *msg;
- struct GNUNET_PeerIdentity id;
struct MeshPeerInfo *peer_info;
struct MeshTunnel *t;
size_t size;
GNUNET_i2s (&msg->oid), ntohl(msg->tid));
return GNUNET_OK;
}
- GNUNET_PEER_resolve (t->prev_hop, &id);
- send_prebuilt_message (message, &id, t);
+ send_prebuilt_message (message, t->prev_hop, t);
GNUNET_STATISTICS_update (stats, "# to origin forwarded", 1, GNUNET_NO);
return GNUNET_OK;
const struct GNUNET_MessageHeader *message)
{
struct GNUNET_MESH_PathACK *msg;
- struct GNUNET_PeerIdentity id;
struct MeshPeerInfo *peer_info;
struct MeshPeerPath *p;
struct MeshTunnel *t;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
" not for us, retransmitting...\n");
- GNUNET_PEER_resolve (t->prev_hop, &id);
peer_info = peer_get (&msg->oid);
- send_prebuilt_message (message, &id, t);
+ send_prebuilt_message (message, t->prev_hop, t);
return GNUNET_OK;
}
const struct GNUNET_MessageHeader *message)
{
struct GNUNET_MESH_TunnelKeepAlive *msg;
- struct GNUNET_PeerIdentity id;
struct MeshTunnel *t;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got a keepalive packet from %s\n",
tunnel_reset_timeout (t);
GNUNET_STATISTICS_update (stats, "# keepalives forwarded", 1, GNUNET_NO);
- send_prebuilt_message (message, NULL, t);
+ send_prebuilt_message (message, t->next_hop, t);
return GNUNET_OK;
}
path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct MeshTunnel *t = cls;
- struct GNUNET_PeerIdentity id;
struct GNUNET_MESH_TunnelKeepAlive *msg;
size_t size = sizeof (struct GNUNET_MESH_TunnelKeepAlive);
char cbuf[size];
msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE);
msg->oid = my_full_id;
msg->tid = htonl (t->id.tid);
- GNUNET_PEER_resolve (t->next_hop, &id);
- send_prebuilt_message (&msg->header, &id, t);
+ send_prebuilt_message (&msg->header, t->next_hop, t);
t->path_refresh_task =
GNUNET_SCHEDULER_add_delayed (refresh_path_time, &path_refresh, t);