* - MAIN FUNCTIONS (main & run)
*
* TODO:
+ * - Backport r24764, r24767.
* - error reporting (CREATE/CHANGE/ADD/DEL?) -- new message!
* - partial disconnect reporting -- same as error reporting?
* - add ping message
/*********************** GLOBAL VARIABLES ****************************/
/******************************************************************************/
+/************************** Configuration parameters **************************/
+
/**
- * Configuration parameters
+ * How often to send tunnel keepalives. Tunnels timeout after 4 missed.
*/
static struct GNUNET_TIME_Relative refresh_path_time;
+
+/**
+ * How often to PUT local application numbers in the DHT.
+ */
static struct GNUNET_TIME_Relative app_announce_time;
+
+/**
+ * How often to PUT own ID in the DHT.
+ */
static struct GNUNET_TIME_Relative id_announce_time;
-static struct GNUNET_TIME_Relative unacknowledged_wait_time;
+
+/**
+ * Maximum time allowed to connect to a peer found by string.
+ */
static struct GNUNET_TIME_Relative connect_timeout;
+
+/**
+ * Default TTL for payload packets.
+ */
static unsigned long long default_ttl;
+
+/**
+ * DHT replication level, see DHT API: GNUNET_DHT_get_start, GNUNET_DHT_put.
+ */
static unsigned long long dht_replication_level;
+
+/**
+ * How many tunnels are we willing to maintain.
+ * Local tunnels are always allowed, even if there are more tunnels than max.
+ */
static unsigned long long max_tunnels;
+
+/**
+ * How many messages *in total* are we willing to queue, divided by number of
+ * tunnels to get tunnel queue size.
+ */
static unsigned long long max_msgs_queue;
+/*************************** Static global variables **************************/
+
/**
* Hostkey generation context
*/
struct MeshTunnelFlowControlInfo fcinfo;
GNUNET_array_append (t->clients, t->nclients, c);
+ fcinfo.t = t;
fcinfo.client = c;
+ fcinfo.peer = NULL;
fcinfo.fwd_ack = t->fwd_pid + 1;
fcinfo.bck_ack = t->nobuffer ? 1 : INITIAL_WINDOW_SIZE - 1;
fcinfo.fwd_pid = t->fwd_pid;
fcinfo.bck_pid = (uint32_t) -1; // Expected next: 0
fcinfo.fc_poll = GNUNET_SCHEDULER_NO_TASK;
+ fcinfo.send_buffer = NULL;
+ fcinfo.send_buffer_n = 0;
+ fcinfo.send_buffer_start = 0;
+ fcinfo.skip = t->fwd_pid;
// FIXME fc buffering is done by context_notify. Confirm this is OK.
t->nclients--;
struct MeshTunnel *t = cls;
struct MeshTunnelFlowControlInfo *fcinfo;
struct GNUNET_PeerIdentity peer;
+ uint32_t ack;
GNUNET_PEER_resolve (id, &peer);
fcinfo = tunnel_get_neighbor_fc (t, &peer);
+ ack = fcinfo->bck_pid + t->bck_queue_max - t->bck_queue_n;
- if (fcinfo->bck_ack != fcinfo->bck_pid &&
- GNUNET_NO == GMC_is_pid_bigger (fcinfo->bck_ack, fcinfo->bck_pid))
+
+ if (fcinfo->bck_ack == ack)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
" Not sending ACK, not needed\n");
return;
}
+ fcinfo->bck_ack = ack;
- fcinfo->bck_ack = t->bck_queue_max - t->bck_queue_n + fcinfo->bck_pid;
+ fcinfo->bck_ack = fcinfo->bck_pid + t->bck_queue_max - t->bck_queue_n;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- " Sending BCK ACK %u\n",
- fcinfo->bck_ack);
- send_ack (t, &peer, fcinfo->bck_ack);
+ " Sending BCK ACK %u (last sent: %u)\n",
+ ack, fcinfo->bck_ack);
+ send_ack (t, &peer, ack);
}
{
}
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_time (c, "MESH", "UNACKNOWLEDGED_WAIT",
- &unacknowledged_wait_time))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _
- ("%s service is lacking key configuration settings (%s). Exiting.\n"),
- "mesh", "unacknowledged wait time");
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
-
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (c, "MESH", "CONNECT_TIMEOUT",
&connect_timeout))