fair, global message buffer implemented
[oweals/gnunet.git] / src / cadet / gnunet-service-cadet-new.c
index af5ac13aea0b681ce320aff0328174190d01c9a7..55c7d1bdb128b9cc6641be840b3bf3c636c0cd6c 100644 (file)
@@ -188,6 +188,11 @@ struct GNUNET_TIME_Relative ratchet_time;
  */
 struct GNUNET_TIME_Relative keepalive_period;
 
+/**
+ * Set to non-zero values to create random drops to test retransmissions.
+ */
+unsigned long long drop_percent;
+
 
 /**
  * Send a message to a client.
@@ -962,17 +967,18 @@ handle_info_tunnels (void *cls,
  * Update the message with information about the connection.
  *
  * @param cls a `struct GNUNET_CADET_LocalInfoTunnel` message to update
- * @param c a connection about which we should store information in @a cls
+ * @param ct a connection about which we should store information in @a cls
  */
 static void
 iter_connection (void *cls,
-                 struct CadetConnection *c)
+                 struct CadetTConnection *ct)
 {
   struct GNUNET_CADET_LocalInfoTunnel *msg = cls;
+  struct CadetConnection *cc = ct->cc;
   struct GNUNET_CADET_ConnectionTunnelIdentifier *h;
 
   h = (struct GNUNET_CADET_ConnectionTunnelIdentifier *) &msg[1];
-  h[msg->connections++] = *(GCC_get_id (c));
+  h[msg->connections++] = *(GCC_get_id (cc));
 }
 
 
@@ -1343,7 +1349,7 @@ run (void *cls,
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_time (c,
                                            "CADET",
-                                           "REFRESHC_CONNECTION_TIME",
+                                           "REFRESH_CONNECTION_TIME",
                                            &keepalive_period))
   {
     GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING,
@@ -1352,7 +1358,22 @@ run (void *cls,
                                "need delay value");
     keepalive_period = GNUNET_TIME_UNIT_MINUTES;
   }
-
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_number (c,
+                                             "CADET",
+                                             "DROP_PERCENT",
+                                             &drop_percent))
+  {
+    drop_percent = 0;
+  }
+  else
+  {
+    LOG (GNUNET_ERROR_TYPE_WARNING, "**************************************\n");
+    LOG (GNUNET_ERROR_TYPE_WARNING, "Cadet is running with DROP enabled.\n");
+    LOG (GNUNET_ERROR_TYPE_WARNING, "This is NOT a good idea!\n");
+    LOG (GNUNET_ERROR_TYPE_WARNING, "Remove DROP_PERCENT from config file.\n");
+    LOG (GNUNET_ERROR_TYPE_WARNING, "**************************************\n");
+  }
   my_private_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (c);
   if (NULL == my_private_key)
   {