};
-/**
- * Struct containing all info possibly needed to build a package when called
- * back by core.
- */
-struct MeshTransmissionDescriptor
-{
- /** ID of the tunnel this packet travels in */
- struct MESH_TunnelID *origin;
-
- /** Who was this message being sent to */
- struct MeshPeerInfo *peer;
-
- /** Ultimate destination of the packet */
- GNUNET_PEER_Id destination;
-
- /** Tunnel it belongs to. */
- struct MeshTunnel *t;
-
- /** Size of the data. */
- size_t data_len;
-
- /** Data itself */
- void *data;
-};
-
-
/**
* Struct containing all information regarding a given peer
*/
unsigned int queue_n;
/**
- * Handle to for queued transmissions
+ * Handle for queued transmissions
*/
struct GNUNET_CORE_TransmitHandle *core_transmit;
};
static size_t
send_core_data_raw (void *cls, size_t size, void *buf)
{
- struct MeshTransmissionDescriptor *info = cls;
- struct GNUNET_MessageHeader *msg;
+ struct GNUNET_MessageHeader *msg = cls;
size_t total_size;
- GNUNET_assert (NULL != info);
- msg = (struct GNUNET_MessageHeader *) info->data;
+ GNUNET_assert (NULL != msg);
total_size = ntohs (msg->size);
if (total_size > size)
return 0;
}
memcpy (buf, msg, total_size);
- GNUNET_free (info->data);
- GNUNET_free (info);
+ GNUNET_free (cls);
return total_size;
}
GNUNET_PEER_Id peer,
struct MeshTunnel *t)
{
- struct MeshTransmissionDescriptor *info;
struct GNUNET_PeerIdentity id;
struct MeshPeerInfo *neighbor;
struct MeshPeerPath *p;
+ void *data;
size_t size;
uint16_t type;
return;
size = ntohs (message->size);
- info = GNUNET_malloc (sizeof (struct MeshTransmissionDescriptor));
- info->data = GNUNET_malloc (size);
- memcpy (info->data, message, size);
+ data = GNUNET_malloc (size);
+ memcpy (data, message, size);
type = ntohs(message->type);
switch (type)
{
- struct GNUNET_MESH_Unicast *m;
+ struct GNUNET_MESH_Unicast *u;
struct GNUNET_MESH_ToOrigin *to;
case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
- m = (struct GNUNET_MESH_Unicast *) info->data;
- m->ttl = htonl (ntohl (m->ttl) - 1);
+ u = (struct GNUNET_MESH_Unicast *) data;
+ u->ttl = htonl (ntohl (u->ttl) - 1);
break;
case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
- to = (struct GNUNET_MESH_ToOrigin *) info->data;
+ to = (struct GNUNET_MESH_ToOrigin *) data;
t->prev_fc.last_pid_sent++; /* FIXME per hop? */
to->pid = htonl (t->prev_fc.last_pid_sent);
}
- info->data_len = size;
GNUNET_PEER_resolve (peer, &id);
neighbor = peer_get (&id);
for (p = neighbor->path_head; NULL != p; p = p->next)
}
#endif
GNUNET_break (0); // FIXME sometimes fails (testing disconnect?)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
" no direct connection to %s\n",
GNUNET_i2s (&id));
- GNUNET_free (info->data);
- GNUNET_free (info);
+ GNUNET_free (data);
return;
}
- info->peer = neighbor;
if (GNUNET_MESSAGE_TYPE_MESH_PATH_ACK == type)
type = 0;
- queue_add (info,
+ queue_add (data,
type,
size,
neighbor,
static void
send_path_ack (struct MeshTunnel *t)
{
- struct MeshTransmissionDescriptor *info;
- struct GNUNET_PeerIdentity id;
+ struct MeshPeerInfo *peer;
- GNUNET_PEER_resolve (t->prev_hop, &id);
- info = GNUNET_malloc (sizeof (struct MeshTransmissionDescriptor));
- info->origin = &t->id;
- info->peer = GNUNET_CONTAINER_multihashmap_get (peers, &id.hashPubKey);
- GNUNET_assert (NULL != info->peer);
+ if (0 == t->prev_hop)
+ {
+ GNUNET_break (0);
+ return;
+ }
- queue_add (info,
+ peer = peer_get_short (t->prev_hop);
+
+ queue_add (&t->id,
GNUNET_MESSAGE_TYPE_MESH_PATH_ACK,
sizeof (struct GNUNET_MESH_PathACK),
- info->peer,
+ peer,
t);
}
if (GNUNET_MESSAGE_TYPE_MESH_UNICAST == pq->type ||
GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN == pq->type)
{
- // Should have been removed on destroy children
+ /* Should have been removed on destroy children */
GNUNET_break (0);
}
queue_destroy (pq, GNUNET_YES);
}
/**
- * Initialize a Flow Control structure
+ * Initialize a Flow Control structure to the initial state.
+ *
+ * @param fc Flow Control structure to initialize.
*/
static void
fc_init (struct MeshFlowControl *fc)
static size_t
send_core_path_ack (void *cls, size_t size, void *buf)
{
- struct MeshTransmissionDescriptor *info = cls;
+ struct MESH_TunnelID *id = cls;
struct GNUNET_MESH_PathACK *msg = buf;
- GNUNET_assert (NULL != info);
+ GNUNET_assert (NULL != id);
if (sizeof (struct GNUNET_MESH_PathACK) > size)
{
GNUNET_break (0);
}
msg->header.size = htons (sizeof (struct GNUNET_MESH_PathACK));
msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_ACK);
- GNUNET_PEER_resolve (info->origin->oid, &msg->oid);
- msg->tid = htonl (info->origin->tid);
+ GNUNET_PEER_resolve (id->oid, &msg->oid);
+ msg->tid = htonl (id->tid);
msg->peer_id = my_full_id;
- GNUNET_free (info);
/* TODO add signature */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "PATH ACK sent!\n");
static void
queue_destroy (struct MeshPeerQueue *queue, int clear_cls)
{
- struct MeshTransmissionDescriptor *dd;
-// unsigned int max;
+ struct MeshFlowControl *fc;
if (GNUNET_YES == clear_cls)
{
" prebuilt message\n");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
" type %s\n",
- GNUNET_MESH_DEBUG_M2S(queue->type));
- dd = queue->cls;
- GNUNET_free (dd->data);
+ GNUNET_MESH_DEBUG_M2S (queue->type));
break;
case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " type create path\n");
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
" type %s unknown!\n",
- GNUNET_MESH_DEBUG_M2S(queue->type));
+ GNUNET_MESH_DEBUG_M2S (queue->type));
}
GNUNET_free_non_null (queue->cls);
}
queue->peer->queue_tail,
queue);
- /* Delete from child_fc in the appropiate tunnel */
-// max = queue->tunnel->fwd_queue_max;
-// GNUNET_PEER_resolve (queue->peer->id, &id);
-// if (NULL != cinfo)
-// { FIXME
-// for (i = 0; i < cinfo->send_buffer_n; i++)
-// {
-// i2 = (cinfo->send_buffer_start + i) % max;
-// if (cinfo->send_buffer[i2] == queue)
-// {
-// /* Found corresponding entry in the send_buffer. Move all others back. */
-// unsigned int j;
-//
-//
-// for (j = i, j2 = 0, j3 = 0; j < cinfo->send_buffer_n - 1; j++)
-// {
-// j2 = (cinfo->send_buffer_start + j) % max;
-// j3 = (cinfo->send_buffer_start + j + 1) % max;
-// cinfo->send_buffer[j2] = cinfo->send_buffer[j3];
-// }
-//
-// cinfo->send_buffer[j3] = NULL;
-// cinfo->send_buffer_n--;
-// }
-// }
-// }
-
+ /* Delete from appropiate fc in the tunnel */
+ if (queue->peer->id == queue->tunnel->next_hop)
+ fc = &queue->tunnel->next_fc;
+ else if (queue->peer->id == queue->tunnel->next_hop)
+ fc = &queue->tunnel->next_fc;
+ else
+ {
+ GNUNET_break (0);
+ return;
+ }
+ fc->queue_n--;
GNUNET_free (queue);
}
{
struct MeshPeerQueue *q;
- struct MeshTransmissionDescriptor *info;
-// struct GNUNET_MESH_Unicast *ucast;
-// struct GNUNET_MESH_ToOrigin *to_orig;
- struct GNUNET_PeerIdentity id;
-// uint32_t pid;
-// uint32_t ack; FIXME
+ struct GNUNET_MESH_Unicast *ucast;
+ struct GNUNET_MESH_ToOrigin *to_orig;
+ struct MeshTunnel* t;
+ uint32_t pid;
+ uint32_t ack;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* selecting message\n");
for (q = peer->queue_head; NULL != q; q = q->next)
{
-// t = q->tunnel;
- info = q->cls;
+ t = q->tunnel;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"********* %s\n",
GNUNET_MESH_DEBUG_M2S(q->type));
switch (q->type)
{
case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
-// ucast = (struct GNUNET_MESH_Unicast *) info->mesh_data->data;
-// pid = ntohl (ucast->pid);
- GNUNET_PEER_resolve (info->peer->id, &id);
-// ack = cinfo->fwd_ack;
+ ucast = (struct GNUNET_MESH_Unicast *) q->cls;
+ pid = ntohl (ucast->pid);
+ ack = t->next_fc.last_ack_recv;
break;
case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
-// to_orig = (struct GNUNET_MESH_ToOrigin *) info->mesh_data->data;
-// pid = ntohl (to_orig->pid);
-// ack = t->bck_ack;
+ to_orig = (struct GNUNET_MESH_ToOrigin *) q->cls;
+ pid = ntohl (to_orig->pid);
+ ack = t->prev_fc.last_ack_recv;
break;
default:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"********* OK!\n");
return q;
}
-// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-// "********* ACK: %u, PID: %u\n",
-// ack, pid);
-// if (GNUNET_NO == GMC_is_pid_bigger(pid, ack))
-// {
-// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-// "********* OK!\n");
-// return q;
-// }
-// else
-// {
-// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-// "********* NEXT!\n");
-// }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "********* ACK: %u, PID: %u\n",
+ ack, pid);
+ if (GNUNET_NO == GMC_is_pid_bigger (pid, ack))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "********* OK!\n");
+ return q;
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "********* NEXT!\n");
+ }
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"********* nothing found\n");
static size_t
queue_send (void *cls, size_t size, void *buf)
{
- struct MeshPeerInfo *peer = cls;
- struct GNUNET_MessageHeader *msg;
- struct MeshPeerQueue *queue;
- struct MeshTunnel *t;
- struct GNUNET_PeerIdentity dst_id;
- struct MeshFlowControl *fc;
- size_t data_size;
+ struct MeshPeerInfo *peer = cls;
+ struct GNUNET_MessageHeader *msg;
+ struct MeshPeerQueue *queue;
+ struct MeshTunnel *t;
+ struct GNUNET_PeerIdentity dst_id;
+ struct MeshFlowControl *fc;
+ size_t data_size;
+ uint16_t type;
- peer->core_transmit = NULL;
+ peer->core_transmit = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* Queue send\n");
- queue = queue_get_next (peer);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* Queue send\n");
+ queue = queue_get_next (peer);
- /* Queue has no internal mesh traffic nor sendable payload */
- if (NULL == queue)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* not ready, return\n");
- if (NULL == peer->queue_head)
- GNUNET_break (0); /* Core tmt_rdy should've been canceled */
+ /* Queue has no internal mesh traffic nor sendable payload */
+ if (NULL == queue)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* not ready, return\n");
+ if (NULL == peer->queue_head)
+ GNUNET_break (0); /* Core tmt_rdy should've been canceled */
+ return 0;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* not empty\n");
+
+ GNUNET_PEER_resolve (peer->id, &dst_id);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "********* towards %s\n",
+ GNUNET_i2s (&dst_id));
+ /* Check if buffer size is enough for the message */
+ if (queue->size > size)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "********* not enough room, reissue\n");
+ peer->core_transmit =
+ GNUNET_CORE_notify_transmit_ready (core_handle,
+ GNUNET_NO,
+ 0,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &dst_id,
+ queue->size,
+ &queue_send,
+ peer);
return 0;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* not empty\n");
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* size ok\n");
- GNUNET_PEER_resolve (peer->id, &dst_id);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "********* towards %s\n",
- GNUNET_i2s(&dst_id));
- /* Check if buffer size is enough for the message */
- if (queue->size > size)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "********* not enough room, reissue\n");
- peer->core_transmit =
- GNUNET_CORE_notify_transmit_ready (core_handle,
- 0,
- 0,
- GNUNET_TIME_UNIT_FOREVER_REL,
- &dst_id,
- queue->size,
- &queue_send,
- peer);
- return 0;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* size ok\n");
+ t = queue->tunnel;
+ GNUNET_assert (0 < t->pending_messages);
+ t->pending_messages--;
+ type = 0;
- t = queue->tunnel;
- GNUNET_assert (0 < t->pending_messages);
- t->pending_messages--;
- if (GNUNET_MESSAGE_TYPE_MESH_UNICAST == queue->type)
- {
- t->next_fc.queue_n--;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "********* unicast: t->q (%u/%u)\n",
- t->next_fc.queue_n, t->queue_max);
- }
- else if (GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN == queue->type)
- {
- t->prev_fc.queue_n--;
+ /* Fill buf */
+ switch (queue->type)
+ {
+ case 0:
+ case GNUNET_MESSAGE_TYPE_MESH_ACK:
+ case GNUNET_MESSAGE_TYPE_MESH_POLL:
+ case GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN:
+ case GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY:
+ case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY:
+ case GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "********* to orig: t->q (%u/%u)\n",
- t->prev_fc.queue_n, t->queue_max);
- }
+ "********* raw: %s\n",
+ GNUNET_MESH_DEBUG_M2S (queue->type));
+ /* Fall through */
+ case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
+ case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
+ data_size = send_core_data_raw (queue->cls, size, buf);
+ msg = (struct GNUNET_MessageHeader *) buf;
+ type = ntohs (msg->type);
+ break;
+ case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* path create\n");
+ data_size = send_core_path_create (queue->cls, size, buf);
+ break;
+ case GNUNET_MESSAGE_TYPE_MESH_PATH_ACK:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* path ack\n");
+ data_size = send_core_path_ack (queue->cls, size, buf);
+ break;
+ default:
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "********* type unknown: %u\n",
+ queue->type);
+ data_size = 0;
+ }
- /* Fill buf */
- switch (queue->type)
- {
- case 0:
- case GNUNET_MESSAGE_TYPE_MESH_ACK:
- case GNUNET_MESSAGE_TYPE_MESH_POLL:
- case GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN:
- case GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY:
- case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY:
- case GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE:
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "********* raw: %s\n",
- GNUNET_MESH_DEBUG_M2S (queue->type));
- /* Fall through */
- case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
- case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
- data_size = send_core_data_raw (queue->cls, size, buf);
- msg = (struct GNUNET_MessageHeader *) buf;
- switch (ntohs (msg->type)) // Type of preconstructed message
- {
- case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
- tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_UNICAST);
- break;
- case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
- tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN);
- break;
- default:
- break;
- }
- break;
- case GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE:
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* path create\n");
- data_size = send_core_path_create (queue->cls, size, buf);
- break;
- case GNUNET_MESSAGE_TYPE_MESH_PATH_ACK:
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* path ack\n");
- data_size = send_core_path_ack (queue->cls, size, buf);
- break;
- default:
- GNUNET_break (0);
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "********* type unknown: %u\n",
- queue->type);
- data_size = 0;
- }
- switch (queue->type)
- {
- case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
- case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
-// if (cinfo->send_buffer[cinfo->send_buffer_start] != queue)
-// { FIXME
-// GNUNET_break (0);
-// GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-// "at pos %u (%p) != %p\n",
-// cinfo->send_buffer_start,
-// cinfo->send_buffer[cinfo->send_buffer_start],
-// queue);
-// }
-// if (cinfo->send_buffer_n > 0)
-// {
-// cinfo->send_buffer[cinfo->send_buffer_start] = NULL;
-// cinfo->send_buffer_n--;
-// cinfo->send_buffer_start++;
-// cinfo->send_buffer_start %= t->fwd_queue_max;
-// }
-// else
-// {
-// GNUNET_break (0);
-// }
- break;
- default:
- break;
- }
+ /* Free queue, but cls was freed by send_core_* */
+ queue_destroy (queue, GNUNET_NO);
- /* Free queue, but cls was freed by send_core_* */
- queue_destroy (queue, GNUNET_NO);
+ /* Send ACK if needed, after accounting for sent ID in fc->queue_n */
+ switch (type)
+ {
+ case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
+ tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_UNICAST);
+ break;
+ case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
+ tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN);
+ break;
+ default:
+ break;
+ }
- if (GNUNET_YES == t->destroy && 0 == t->pending_messages)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* destroying tunnel!\n");
- tunnel_destroy (t);
- }
+ if (GNUNET_YES == t->destroy && 0 == t->pending_messages)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* destroying tunnel!\n");
+ tunnel_destroy (t);
+ }
- /* If more data in queue, send next */
- queue = queue_get_next (peer);
- if (NULL != queue)
+ /* If more data in queue, send next */
+ queue = queue_get_next (peer);
+ if (NULL != queue)
+ {
+ struct GNUNET_PeerIdentity id;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* more data!\n");
+ GNUNET_PEER_resolve (peer->id, &id);
+ peer->core_transmit =
+ GNUNET_CORE_notify_transmit_ready(core_handle,
+ 0,
+ 0,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &id,
+ queue->size,
+ &queue_send,
+ peer);
+ }
+ else if (NULL != peer->queue_head)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "********* %s stalled\n",
+ GNUNET_i2s (&my_full_id));
+ if (peer->id == t->next_hop)
+ fc = &t->next_fc;
+ else if (peer->id == t->prev_hop)
+ fc = &t->prev_fc;
+ else
{
- struct GNUNET_PeerIdentity id;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* more data!\n");
- GNUNET_PEER_resolve (peer->id, &id);
- peer->core_transmit =
- GNUNET_CORE_notify_transmit_ready(core_handle,
- 0,
- 0,
- GNUNET_TIME_UNIT_FOREVER_REL,
- &id,
- queue->size,
- &queue_send,
- peer);
+ GNUNET_break (0);
+ fc = NULL;
}
- else
+ if (NULL != fc && GNUNET_SCHEDULER_NO_TASK == fc->poll_task)
{
- if (NULL != peer->queue_head)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "********* %s stalled\n",
- GNUNET_i2s(&my_full_id));
- if (peer->id == t->next_hop)
- fc = &t->next_fc;
- else
- fc = &t->prev_fc;
- if (GNUNET_SCHEDULER_NO_TASK == fc->poll_task)
- {
- fc->t = t;
- fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
- &tunnel_poll, fc);
- }
- }
+ fc->t = t;
+ fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
+ &tunnel_poll, fc);
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* return %d\n", data_size);
- return data_size;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* Return %d\n", data_size);
+ return data_size;
}
GNUNET_STATISTICS_update(stats,
"# messages dropped (buffer full)",
1, GNUNET_NO);
- return; // Drop message
+ return; /* Drop message */
}
(*n)++;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
" path is for tunnel %s [%X].\n", GNUNET_i2s (pi), tid);
t = tunnel_get (pi, tid);
- if (NULL == t) // FIXME only for INCOMING tunnels?
+ if (NULL == t)
{
uint32_t opt;
t = tunnel_new (GNUNET_PEER_intern (pi), tid, NULL, 0);
if (NULL == t)
{
- // FIXME notify failure
+ GNUNET_break (0);
return GNUNET_OK;
}
opt = ntohl (msg->opt);
t->queue_max = 1;
}
- // FIXME only assign a local tid if a local client is interested (on demand)
- while (NULL != tunnel_get_incoming (next_local_tid))
- next_local_tid = (next_local_tid + 1) | GNUNET_MESH_LOCAL_TUNNEL_ID_SERV;
- t->local_tid_dest = next_local_tid++;
- next_local_tid = next_local_tid | GNUNET_MESH_LOCAL_TUNNEL_ID_SERV;
- // FIXME end
-
tunnel_reset_timeout (t);
GMC_hash32 (t->local_tid_dest, &hash);
if (GNUNET_OK !=
if (own_pos == size - 1)
{
/* It is for us! Send ack. */
+ // TODO: check port number / client registration
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " It's for us!\n");
peer_info_add_path_to_origin (orig_peer_info, path, GNUNET_NO);
t->dest = myid;
+
+ while (NULL != tunnel_get_incoming (next_local_tid))
+ next_local_tid = (next_local_tid + 1) | GNUNET_MESH_LOCAL_TUNNEL_ID_SERV;
+ t->local_tid_dest = next_local_tid++;
+ next_local_tid = next_local_tid | GNUNET_MESH_LOCAL_TUNNEL_ID_SERV;
+
send_path_ack (t);
}
else
{
struct GNUNET_MESH_ManipulatePath *msg;
struct GNUNET_PeerIdentity *pi;
- struct MeshPeerPath *path;
struct MeshTunnel *t;
unsigned int own_pos;
unsigned int i;
GNUNET_break_op (0);
return GNUNET_OK;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Creating path...\n");
- path = path_new (size);
own_pos = 0;
for (i = 0; i < size; i++)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ... adding %s\n",
- GNUNET_i2s (&pi[i]));
- path->peers[i] = GNUNET_PEER_intern (&pi[i]);
- if (path->peers[i] == myid)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " %u: %s\n", i, GNUNET_i2s (&pi[i]));
+ if (GNUNET_PEER_search (&pi[i]) == myid)
own_pos = i;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Own position: %u\n", own_pos);
- if (own_pos < path->length - 1)
- send_prebuilt_message (message, path->peers[own_pos + 1], t);
+ if (own_pos < size - 1)
+ send_prebuilt_message (message, t->next_hop, t);
else
send_client_tunnel_destroy (t);
-// tunnel_delete_peer (t, path->peers[path->length - 1]); FIXME
- path_destroy (path);
return GNUNET_OK;
}
" for tunnel %s [%u]\n",
GNUNET_i2s (&msg->oid), ntohl (msg->tid));
t = tunnel_get (&msg->oid, ntohl (msg->tid));
- /* Check signature */
if (NULL == t)
{
/* Probably already got the message from another path,
{
struct GNUNET_MESH_Poll *msg;
struct MeshTunnel *t;
+ GNUNET_PEER_Id id;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got an POLL packet from %s!\n",
GNUNET_i2s (peer));
}
/* Is this a forward or backward ACK? */
- if (t->prev_hop != GNUNET_PEER_search(peer))
+ id = GNUNET_PEER_search(peer);
+ if (t->next_hop == id)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " from FWD\n");
- /* FIXME cinfo->bck_ack = cinfo->fwd_pid; // mark as ready to send */
tunnel_send_bck_ack (t, GNUNET_MESSAGE_TYPE_MESH_POLL);
}
- else
+ else if (t->prev_hop == id)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " from BCK\n");
tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_POLL);
}
+ else
+ GNUNET_break (0);
return GNUNET_OK;
}