* Only present (non-NULL) at the destination of a tunnel.
*/
struct MeshChannelReliability *bck_rel;
+
+ /**
+ * Is the root prevented from sending more data? (We "owe" him an ACK).
+ */
+ int blocked_fwd;
+
+ /**
+ * Is the dest prevented from sending more data? (We "owe" him an ACK).
+ */
+ int blocked_bck;
};
* ID of the client, mainly for debug messages
*/
unsigned int id;
-
- /**
- * Is this client prevented from sending more data? (We "owe" him an ACK).
- */
- int blocked;
};
{
struct GNUNET_MESH_LocalAck msg;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "send local %s ack on %s:%X towards %p\n",
+ fwd ? "FWD" : "BCK", GNUNET_h2s (&ch->t->id), ch->gid, c);
+
if (NULL == c
|| ( fwd && (0 == ch->lid_root || c != ch->root))
|| (!fwd && (0 == ch->lid_dest || c != ch->dest)) )
c->handle,
&msg.header,
GNUNET_NO);
- c->blocked = GNUNET_NO;
+ if (fwd)
+ ch->blocked_fwd = GNUNET_NO;
+ else
+ ch->blocked_bck = GNUNET_NO;
}
memcpy (data, message, size);
type = ntohs (message->type);
- if (GNUNET_MESSAGE_TYPE_MESH_FWD == type ||
- GNUNET_MESSAGE_TYPE_MESH_BCK == type)
+ switch (type)
{
- struct GNUNET_MESH_Encrypted *msg;
+ struct GNUNET_MESH_Encrypted *emsg;
+ struct GNUNET_MESH_ACK *amsg;
+ struct GNUNET_MESH_Poll *pmsg;
uint32_t ttl;
- msg = (struct GNUNET_MESH_Encrypted *) data;
- ttl = ntohl (msg->ttl);
- if (0 == ttl)
- {
- GNUNET_break_op (0);
- return;
- }
- msg->ttl = htonl (ttl - 1);
- msg->pid = htonl (fwd ? c->fwd_fc.next_pid++ : c->bck_fc.next_pid++);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " pid %u\n", ntohl (msg->pid));
+ case GNUNET_MESSAGE_TYPE_MESH_FWD:
+ case GNUNET_MESSAGE_TYPE_MESH_BCK:
+ emsg = (struct GNUNET_MESH_Encrypted *) data;
+ ttl = ntohl (emsg->ttl);
+ if (0 == ttl)
+ {
+ GNUNET_break_op (0);
+ return;
+ }
+ emsg->tid = c->t->id;
+ emsg->cid = htonl (c->id);
+ emsg->ttl = htonl (ttl - 1);
+ emsg->pid = htonl (fwd ? c->fwd_fc.next_pid++ : c->bck_fc.next_pid++);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " pid %u\n", ntohl (emsg->pid));
+ break;
+
+ case GNUNET_MESSAGE_TYPE_MESH_ACK:
+ amsg = (struct GNUNET_MESH_ACK *) data;
+ amsg->tid = c->t->id;
+ amsg->cid = htonl (c->id);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ack %u\n", ntohl (amsg->ack));
+ break;
+
+ case GNUNET_MESSAGE_TYPE_MESH_POLL:
+ pmsg = (struct GNUNET_MESH_Poll *) data;
+ pmsg->tid = c->t->id;
+ pmsg->cid = htonl (c->id);
+ pmsg->pid = htonl (fwd ? c->fwd_fc.last_pid_sent : c->bck_fc.last_pid_sent);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " poll %u\n", ntohl (pmsg->pid));
+ break;
+
+ default:
+ GNUNET_break (0);
}
queue_add (data,
msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_POLL);
msg.header.size = htons (sizeof (msg));
- msg.pid = htonl (fc->last_pid_sent);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " *** pid (%u)!\n", fc->last_pid_sent);
send_prebuilt_message_connection (&msg.header, c, NULL, fc == &c->fwd_fc);
fc->poll_time = GNUNET_TIME_STD_BACKOFF (fc->poll_time);
/**
- * Send an ACK to a client is needed.
+ * Send an ACK to a client if needed.
*
* @param ch Channel this is regarding.
* @param fwd Is this about fwd traffic? (ACk goes the opposite direction).
channel_send_client_ack (struct MeshChannel *ch, int fwd)
{
struct MeshClient *c;
+ int blocked;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Channel send client %s ack on %s:%X\n",
+ fwd ? "FWD" : "BCK", GNUNET_h2s (&ch->t->id), ch->gid);
+
+ /* Check for buffer space */
+ if (0 >= tunnel_get_buffer (ch->t, fwd))
+ return;
/* Client to receive the ACK (fwd indicates traffic to be ACK'd) */
c = fwd ? ch->root : ch->dest;
- if (GNUNET_YES == c->blocked)
+ blocked = fwd ? ch->blocked_fwd : ch->blocked_bck;
+ if (GNUNET_YES == blocked)
send_local_ack (ch, c, fwd);
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client not blocked\n");
}
unsigned int cs;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Channel send %s ack on %s:%X\n",
+ "Channel send connection %s ack on %s:%X\n",
fwd ? "FWD" : "BCK", GNUNET_h2s (&ch->t->id), ch->gid);
/* Count connections, how many messages are already allowed */
return NULL;
}
+// char salt[] = "salt";
+// GNUNET_CRYPTO_kdf (&t->e_key, sizeof (struct GNUNET_CRYPTO_AesSessionKey),
+// salt, sizeof (salt),
+// &t->e_key, sizeof (struct GNUNET_CRYPTO_AesSessionKey),
+// &my_full_id, sizeof (struct GNUNET_PeerIdentity),
+// GNUNET_PEER_resolve2 (t->peer->id), sizeof (struct GNUNET_PeerIdentity),
+// NULL);
+// GNUNET_CRYPTO_kdf (&t->d_key, sizeof (struct GNUNET_CRYPTO_AesSessionKey),
+// salt, sizeof (salt),
+// &t->d_key, sizeof (struct GNUNET_CRYPTO_AesSessionKey),
+// GNUNET_PEER_resolve2 (t->peer->id), sizeof (struct GNUNET_PeerIdentity),
+// &my_full_id, sizeof (struct GNUNET_PeerIdentity),
+// NULL);
+
return t;
}
ch->root = owner;
ch->lid_root = lid_root;
ch->t = t;
+ ch->blocked_fwd = GNUNET_YES;
+ ch->blocked_bck = GNUNET_YES;
GNUNET_CONTAINER_DLL_insert (t->channel_head, t->channel_tail, ch);
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;
type = ntohs (msg->type);
else
data_size = send_core_data_raw (queue->cls, size, buf);
break;
+ case GNUNET_MESSAGE_TYPE_MESH_UNICAST:
+ case GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN:
+ case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE:
+ case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY:
+ /* This should be encapsulted */
+ GNUNET_break (0);
+ break;
default:
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "* type unknown: %u\n",
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " by client %u\n", c->id);
- c->blocked = GNUNET_YES;
msg = (struct GNUNET_MESH_LocalData *) message;
return;
}
+ if (fwd)
+ ch->blocked_fwd = GNUNET_YES;
+ else
+ ch->blocked_bck = GNUNET_YES;
+
/* Ok, everything is correct, send the message
* (pretend we got it from a mesh peer)
*/