/****************** GENERAL HELPER FUNCTIONS ************************/
/******************************************************************************/
-/**
- * Check if one pid is bigger than other, accounting for overflow.
- *
- * @param bigger Argument that should be bigger.
- * @param smaller Argument that should be smaller.
- *
- * @return True if bigger (arg1) has a higher value than smaller (arg 2).
- */
-static int
-is_pid_bigger (uint32_t bigger, uint32_t smaller)
-{
- return (GNUNET_YES == PID_OVERFLOW(smaller, bigger) ||
- (bigger > smaller && GNUNET_NO == PID_OVERFLOW(bigger, smaller)));
-}
-
-/**
- * Get the higher ACK value out of two values, taking in account overflow.
- *
- * @param a First ACK value.
- * @param b Second ACK value.
- *
- * @return Highest ACK value from the two.
- */
-static uint32_t
-max_pid (uint32_t a, uint32_t b)
-{
- if (is_pid_bigger(a, b))
- return a;
- return b;
-}
-
-
-/**
- * Get the lower ACK value out of two values, taking in account overflow.
- *
- * @param a First ACK value.
- * @param b Second ACK value.
- *
- * @return Lowest ACK value from the two.
- */
-static uint32_t
-min_pid (uint32_t a, uint32_t b)
-{
- if (is_pid_bigger(a, b))
- return b;
- return a;
-}
-
-
/**
* Decrements the reference counter and frees all resources if needed
*
type = ntohs (payload->type);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending to clients...\n");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "message of type %u\n", type);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "message of type %s\n",
+ GNUNET_MESH_DEBUG_M2S (type));
memcpy (cbuf, msg, sizeof (cbuf));
switch (htons (msg->type))
/**
- * Notify a the client of a tunnel about how many more
+ * Notify a client of a tunnel about how many more
* payload packages will we accept on a given tunnel,
* distinguishing between root and leaf clients.
*
struct MeshPeerInfo *neighbor;
struct MeshPeerPath *p;
size_t size;
+ uint16_t type;
// GNUNET_TRANSPORT_try_connect(); FIXME use?
info->mesh_data = GNUNET_malloc (sizeof (struct MeshData));
info->mesh_data->data = GNUNET_malloc (size);
memcpy (info->mesh_data->data, message, size);
- if (ntohs(message->type) == GNUNET_MESSAGE_TYPE_MESH_UNICAST)
+ type = ntohs(message->type);
+ if (GNUNET_MESSAGE_TYPE_MESH_UNICAST == type)
{
struct GNUNET_MESH_Unicast *m;
}
if (NULL == p)
{
+#if MESH_DEBUG
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ " %s IS NOT DIRECTLY CONNECTED\n",
+ GNUNET_i2s(peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ " PATHS TO %s:\n",
+ GNUNET_i2s(peer));
+ for (p = neighbor->path_head; NULL != p; p = p->next)
+ {
+ struct GNUNET_PeerIdentity debug_id;
+ unsigned int i;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ " path with %u hops through:\n",
+ p->length);
+ for (i = 0; i < p->length; i++)
+ {
+ GNUNET_PEER_resolve(p->peers[i], &debug_id);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ " hop %u: %s\n",
+ i, GNUNET_i2s(&debug_id));
+ }
+ }
+#endif
GNUNET_break (0); // FIXME sometimes fails (testing disconnect?)
GNUNET_free (info->mesh_data->data);
GNUNET_free (info->mesh_data);
return;
}
info->peer = neighbor;
+ if (GNUNET_MESSAGE_TYPE_MESH_PATH_ACK == type)
+ {
+ /*
+ * TODO: in this case we only need the service to retransmit
+ * the message down the path. If we pass the real type to queue_add,
+ * queue_send will try to build the message from scratch. This can
+ * probably be done by some other way instead of deleteing the type
+ * info.
+ */
+ type = 0;
+ }
queue_add (info,
- 0,
+ type,
size,
neighbor,
t);
clinfo.fwd_ack = t->fwd_pid + 1;
clinfo.bck_ack = t->nobuffer ? 1 : INITIAL_WINDOW_SIZE;
clinfo.fwd_pid = t->fwd_pid;
+ clinfo.bck_pid = (uint32_t) -1; // Expected next: 0
t->nclients--;
GNUNET_array_append (t->clients_fc, t->nclients, clinfo);
}
&peer->hashPubKey);
if (NULL == cinfo)
{
+ uint32_t delta;
+
cinfo = GNUNET_malloc (sizeof (struct MeshTunnelChildInfo));
cinfo->id = GNUNET_PEER_intern (peer);
cinfo->skip = t->fwd_pid;
- cinfo->fwd_ack = t->fwd_pid + t->fwd_queue_max - t->fwd_queue_n; // FIXME review
+
+ delta = t->nobuffer ? 1 : INITIAL_WINDOW_SIZE;
+ cinfo->fwd_ack = t->fwd_pid + delta;
+ cinfo->bck_ack = delta;
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multihashmap_put (t->children_fc,
}
+/**
+ * Get the Flow Control info of a client.
+ *
+ * @param t Tunnel on which to look.
+ * @param c Client whose ACK to get.
+ *
+ * @return ACK value.
+ */
+static struct MeshTunnelClientInfo *
+tunnel_get_client_fc (struct MeshTunnel *t,
+ struct MeshClient *c)
+{
+ unsigned int i;
+
+ for (i = 0; i < t->nclients; i++)
+ {
+ if (t->clients[i] != c)
+ continue;
+ return &t->clients_fc[i];
+ }
+ GNUNET_assert (0);
+ return NULL; // avoid compiler / coverity complaints
+}
+
+
/**
* Iterator to get the appropiate ACK value from all children nodes.
*
if (0 == ctx.nchildren)
return -1LL;
- if (GNUNET_YES == t->nobuffer && is_pid_bigger(ctx.max_child_ack, t->fwd_pid))
+ if (GNUNET_YES == t->nobuffer && GMC_is_pid_bigger(ctx.max_child_ack, t->fwd_pid))
ctx.max_child_ack = t->fwd_pid + 1; // Might overflow, it's ok.
return (int64_t) ctx.max_child_ack;
}
-/**
- * Get the ACK value of a client in a particular tunnel.
- *
- * @param t Tunnel on which to look.
- * @param c Client whose ACK to get.
- *
- * @return ACK value.
- */
-uint32_t // FIXME fc Is this funcion needed anymore?
-tunnel_get_client_fwd_ack (struct MeshTunnel *t,
- struct MeshClient *c)
-{
- unsigned int i;
-
- for (i = 0; i < t->nclients; i++)
- {
- if (t->clients[i] != c)
- continue;
- return t->clients_fc[i].fwd_ack;
- }
- GNUNET_break (0);
- return UINT32_MAX;
-}
-
-
/**
* Get the highest ACK value of all clients in a particular tunnel,
* according to the buffering/speed settings.
{
if (-1 == ack ||
(GNUNET_YES == t->speed_min &&
- GNUNET_YES == is_pid_bigger (ack, t->clients_fc[i].fwd_ack)) ||
+ GNUNET_YES == GMC_is_pid_bigger (ack, t->clients_fc[i].fwd_ack)) ||
(GNUNET_NO == t->speed_min &&
- GNUNET_YES == is_pid_bigger (t->clients_fc[i].fwd_ack, ack)))
+ GNUNET_YES == GMC_is_pid_bigger (t->clients_fc[i].fwd_ack, ack)))
{
ack = t->clients_fc[i].fwd_ack;
}
}
- if (GNUNET_YES == t->nobuffer && is_pid_bigger(ack, t->fwd_pid))
+ if (GNUNET_YES == t->nobuffer && GMC_is_pid_bigger(ack, t->fwd_pid))
ack = (uint32_t) t->fwd_pid + 1; // Might overflow, it's ok.
return (uint32_t) ack;
if (-1 == child_ack)
{
// Node has no children, child_ack AND core buffer are irrelevant.
- GNUNET_break (-1 != client_ack); // No children AND no clients? Not good!
+ GNUNET_break (-1 != client_ack); // No children AND no clients? Not good! // FIXME fc
return (uint32_t) client_ack;
}
if (GNUNET_YES == t->speed_min)
{
- ack = min_pid ((uint32_t) child_ack, ack);
- ack = min_pid ((uint32_t) client_ack, ack);
+ ack = GMC_min_pid ((uint32_t) child_ack, ack);
+ ack = GMC_min_pid ((uint32_t) client_ack, ack);
}
else
{
- ack = max_pid ((uint32_t) child_ack, ack);
- ack = max_pid ((uint32_t) client_ack, ack);
+ ack = GMC_max_pid ((uint32_t) child_ack, ack);
+ ack = GMC_max_pid ((uint32_t) client_ack, ack);
}
- if (GNUNET_YES == t->nobuffer && is_pid_bigger(ack, t->fwd_pid))
+ if (GNUNET_YES == t->nobuffer && GMC_is_pid_bigger(ack, t->fwd_pid))
ack = t->fwd_pid + 1; // Might overflow 32 bits, it's ok!
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "c %u, bf %u, ch %u, cl %u, ACK: %u\n",
count, buffer_free, child_ack, client_ack, ack);
cinfo = tunnel_get_neighbor_fc (t, &peer);
if (cinfo->bck_ack != cinfo->pid &&
- GNUNET_NO == is_pid_bigger (cinfo->bck_ack, cinfo->pid))
+ GNUNET_NO == GMC_is_pid_bigger (cinfo->bck_ack, cinfo->pid))
return;
cinfo->bck_ack++;
ack = clinfo->bck_pid;
ack += t->nobuffer ? 1 : INITIAL_WINDOW_SIZE;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ " sending ack to client %u: %u\n",
+ t->clients[i]->id, ack);
send_local_ack(t->clients[i], t, ack);
clinfo->bck_ack = ack;
}
static void
tunnel_send_bck_ack (struct MeshTunnel *t, uint16_t type)
{
- if (NULL != t->owner)
- {
- send_client_tunnel_ack (t->owner, t);
- return;
- }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending BCK ACK on tunnel %u [%u]\n",
+ t->id.oid, t->id.tid);
/* Is it after data to_origin retransmission? */
switch (type)
{
}
if (t->bck_queue_max > t->bck_queue_n * 2)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not sending ACK, buffer free\n");
- return;
+// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Not sending ACK, buffer free\n");
+// return;
}
break;
case GNUNET_MESSAGE_TYPE_MESH_ACK:
case GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK:
+ // FIXME fc
break;
default:
GNUNET_break (0);
t->bck_queue_max = t->fwd_queue_max;
t->tree = tree_new (owner);
t->owner = client;
- t->bck_ack = INITIAL_WINDOW_SIZE;
- t->last_fwd_ack = INITIAL_WINDOW_SIZE;
+ t->fwd_pid = (uint32_t) -1; // Next (expected) = 0
+ t->bck_pid = (uint32_t) -1; // Next (expected) = 0
+ t->bck_ack = INITIAL_WINDOW_SIZE - 1;
+ t->last_fwd_ack = INITIAL_WINDOW_SIZE - 1;
t->local_tid = local;
t->children_fc = GNUNET_CONTAINER_multihashmap_create (8);
n_tunnels++;
mc = (struct GNUNET_MESH_Multicast *) mh;
mh = (struct GNUNET_MessageHeader *) &mc[1];
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- " multicast, payload type %u\n", ntohs (mh->type));
+ " multicast, payload type %s\n",
+ GNUNET_MESH_DEBUG_M2S (ntohs (mh->type)));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
" multicast, payload size %u\n", ntohs (mh->size));
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " type %u\n",
- ntohs (mh->type));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " type %s\n",
+ GNUNET_MESH_DEBUG_M2S (ntohs (mh->type)));
}
}
#endif
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* size ok\n");
t = queue->tunnel;
- t->fwd_queue_n--;
+ if (GNUNET_MESSAGE_TYPE_MESH_UNICAST == queue->type)
+ {
+ t->fwd_queue_n--;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* unicast: %u\n");
+ }
+ else if (GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN == queue->type)
+ {
+ t->bck_queue_n--;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* to origin\n");
+ }
/* Fill buf */
switch (queue->type)
{
- case 0: // RAW data (preconstructed message, retransmission, etc.)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* raw\n");
- 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_MULTICAST:
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* multicast\n");
- data_size = send_core_data_multicast(queue->cls, size, buf);
- tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_MULTICAST);
- 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);
+ case 0:
+ case GNUNET_MESSAGE_TYPE_MESH_ACK:
+ case GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN:
+ case GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "********* raw: %u\n",
+ 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_PATH_ACK:
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* path ack\n");
- data_size = send_core_path_ack(queue->cls, size, buf);
+ case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
+ tunnel_send_bck_ack(t, GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN);
break;
- default:
- GNUNET_break (0);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* type unknown\n");
- data_size = 0;
+ default:
+ break;
+ }
+ break;
+ case GNUNET_MESSAGE_TYPE_MESH_MULTICAST:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* multicast\n");
+ data_size = send_core_data_multicast(queue->cls, size, buf);
+ tunnel_send_fwd_ack (t, GNUNET_MESSAGE_TYPE_MESH_MULTICAST);
+ 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_DEBUG,
+ "********* type unknown: %u\n",
+ queue->type);
+ data_size = 0;
}
/* Free queue, but cls was freed by send_core_* */
unsigned int *max;
unsigned int *n;
+ n = NULL;
if (GNUNET_MESSAGE_TYPE_MESH_UNICAST == type ||
GNUNET_MESSAGE_TYPE_MESH_MULTICAST == type)
{
n = &t->fwd_queue_n;
max = &t->fwd_queue_max;
}
- else
+ else if (GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN == type)
{
n = &t->bck_queue_n;
max = &t->bck_queue_max;
}
- if (*n >= *max)
- {
- if (NULL == t->owner)
- GNUNET_break_op(0); // TODO: kill connection?
- else
- GNUNET_break(0);
- return; // Drop message
+ if (NULL != n) {
+ if (*n >= *max)
+ {
+ if (NULL == t->owner)
+ GNUNET_break_op(0); // TODO: kill connection?
+ else
+ GNUNET_break(0);
+ return; // Drop message
+ }
+ (*n)++;
}
- (*n)++;
queue = GNUNET_malloc (sizeof (struct MeshPeerQueue));
queue->cls = cls;
queue->type = type;
return GNUNET_OK;
}
msg = (struct GNUNET_MESH_Unicast *) message;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " of type %u\n",
- ntohs (msg[1].header.type));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " of type %s\n",
+ GNUNET_MESH_DEBUG_M2S (ntohs (msg[1].header.type)));
/* Check tunnel */
t = tunnel_get (&msg->oid, ntohl (msg->tid));
if (NULL == t)
}
t->skip += (pid - t->fwd_pid) - 1;
t->fwd_pid = pid;
- if (is_pid_bigger (pid, t->last_fwd_ack))
+ if (GMC_is_pid_bigger (pid, t->last_fwd_ack))
{
GNUNET_STATISTICS_update (stats, "# unsolicited unicast", 1, GNUNET_NO);
GNUNET_break_op (0);
GNUNET_CONTAINER_multihashmap_iterate (t->children_fc,
&tunnel_add_skip,
&neighbor);
- if (is_pid_bigger (pid, cinfo->fwd_ack))
+ if (GMC_is_pid_bigger (pid, cinfo->fwd_ack))
{
GNUNET_STATISTICS_update (stats, "# unsolicited unicast", 1, GNUNET_NO);
GNUNET_break_op (0);
return GNUNET_OK;
}
msg = (struct GNUNET_MESH_ToOrigin *) message;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " of type %u\n",
- ntohs (msg[1].header.type));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " of type %s\n",
+ GNUNET_MESH_DEBUG_M2S (ntohs (msg[1].header.type)));
t = tunnel_get (&msg->oid, ntohl (msg->tid));
if (NULL == t)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
" it's for us! sending to clients...\n");
- if (NULL == t->owner)
- {
- /* got data packet for ownerless tunnel */
- GNUNET_STATISTICS_update (stats, "# data on ownerless tunnel",
- 1, GNUNET_NO);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " no clients!\n");
- GNUNET_break_op (0);
- return GNUNET_OK;
- }
/* TODO signature verification */
memcpy (cbuf, message, size);
copy = (struct GNUNET_MESH_ToOrigin *) cbuf;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got an ACK packet from %s!\n",
GNUNET_i2s (peer));
msg = (struct GNUNET_MESH_ACK *) message;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " of type %u\n",
- ntohs (msg[1].header.type));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " of type %s\n",
+ GNUNET_MESH_DEBUG_M2S (ntohs (msg[1].header.type)));
t = tunnel_get (&msg->oid, ntohl (msg->tid));
if (NULL == t)
return;
}
+ /* PID should be as expected */
+ if (ntohl (data_msg->pid) != t->fwd_pid + 1)
+ {
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Unicast PID, expected %u, got %u\n",
+ t->fwd_pid + 1, ntohl (data_msg->pid));
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+
/* Ok, everything is correct, send the message
* (pretend we got it from a mesh peer)
*/
{
+ /* Work around const limitation */
char buf[ntohs (message->size)] GNUNET_ALIGN;
struct GNUNET_MESH_Unicast *copy;
- /* Work around const limitation */
copy = (struct GNUNET_MESH_Unicast *) buf;
memcpy (buf, data_msg, size);
copy->oid = my_full_id;
copy->tid = htonl (t->id.tid);
copy->ttl = htonl (default_ttl);
- copy->pid = htonl (t->fwd_pid + 1);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
" calling generic handler...\n");
handle_mesh_data_unicast (NULL, &my_full_id, ©->header, NULL, 0);
const struct GNUNET_MessageHeader *message)
{
struct GNUNET_MESH_ToOrigin *data_msg;
- struct GNUNET_PeerIdentity id;
+ struct MeshTunnelClientInfo *clinfo;
struct MeshClient *c;
struct MeshTunnel *t;
MESH_TunnelNumber tid;
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- GNUNET_PEER_resolve (t->id.oid, &id);
+
+ /* PID should be as expected */
+ clinfo = tunnel_get_client_fc (t, c);
+ if (ntohl (data_msg->pid) != clinfo->bck_pid + 1)
+ {
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "To Origin PID, expected %u, got %u\n",
+ clinfo->bck_pid + 1, ntohl (data_msg->pid));
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
/* Ok, everything is correct, send the message
* (pretend we got it from a mesh peer)
/* Work around const limitation */
copy = (struct GNUNET_MESH_ToOrigin *) buf;
memcpy (buf, data_msg, size);
- copy->oid = id;
+ GNUNET_PEER_resolve (t->id.oid, ©->oid);
copy->tid = htonl (t->id.tid);
+ copy->ttl = htonl (default_ttl);
+ GNUNET_assert (ntohl (copy->pid) == (t->bck_pid + 1));
copy->sender = my_full_id;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
" calling generic handler...\n");
return;
}
+ /* PID should be as expected */
+ if (ntohl (data_msg->pid) != t->fwd_pid + 1)
+ {
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Multicast PID, expected %u, got %u\n",
+ t->fwd_pid + 1, ntohl (data_msg->pid));
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+
{
char buf[ntohs (message->size)] GNUNET_ALIGN;
struct GNUNET_MESH_Multicast *copy;
copy->oid = my_full_id;
copy->tid = htonl (t->id.tid);
copy->ttl = htonl (default_ttl);
- copy->pid = htonl (t->fwd_pid + 1);
+ GNUNET_assert (ntohl (copy->pid) == (t->fwd_pid + 1));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
" calling generic handler...\n");
handle_mesh_data_multicast (client, &my_full_id, ©->header, NULL, 0);
t = tunnel_get_by_local_id (c, tid);
if (NULL == t)
{
- GNUNET_break (0);
+ GNUNET_break (0); // FIXME fc
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
core_init (void *cls, struct GNUNET_CORE_Handle *server,
const struct GNUNET_PeerIdentity *identity)
{
+ static int i = 0;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core init\n");
core_handle = server;
if (0 != memcmp (identity, &my_full_id, sizeof (my_full_id)) ||
NULL == server)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Wrong CORE service\n"));
- GNUNET_SCHEDULER_shutdown ();
+ GNUNET_SCHEDULER_shutdown (); // Try gracefully
+ if (10 < i++)
+ GNUNET_abort(); // Try harder
}
return;
}