convert fs publish to MQ
[oweals/gnunet.git] / src / core / gnunet-service-core_kx.c
index 7f4adc2adce9f21bfba454373b8afeaa407c0687..6a1924e5409b327b3deb842d6360cd050a3c9405 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2009-2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2009-2013 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -659,11 +659,9 @@ send_key (struct GSC_KeyExchangeInfo *kx);
  * Task that will retry #send_key() if our previous attempt failed.
  *
  * @param cls our `struct GSC_KeyExchangeInfo`
- * @param tc scheduler context
  */
 static void
-set_key_retry_task (void *cls,
-                    const struct GNUNET_SCHEDULER_TaskContext *tc)
+set_key_retry_task (void *cls)
 {
   struct GSC_KeyExchangeInfo *kx = cls;
 
@@ -747,9 +745,10 @@ GSC_KX_start (const struct GNUNET_PeerIdentity *pid)
   {
     /* peer with "higher" identity starts a delayed  KX, if the "lower" peer
      * does not start a KX since he sees no reasons to do so  */
-    kx->retry_set_key_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
-                                                           &set_key_retry_task,
-                                                           kx);
+    kx->retry_set_key_task
+      = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                     &set_key_retry_task,
+                                     kx);
   }
   return kx;
 }
@@ -917,9 +916,9 @@ GSC_KX_handle_ephemeral_key (struct GSC_KeyExchangeInfo *kx,
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                _("Ephemeral key message from peer `%s' rejected as its validity range does not match our system time (%llu not in [%llu,%llu]).\n"),
                GNUNET_i2s (&kx->peer),
-               now.abs_value_us,
-               start_t.abs_value_us,
-               end_t.abs_value_us);
+               (unsigned long long) now.abs_value_us,
+                (unsigned long long) start_t.abs_value_us,
+                (unsigned long long) end_t.abs_value_us);
     return;
   }
   kx->other_ephemeral_key = m->ephemeral_key;
@@ -1060,9 +1059,14 @@ GSC_KX_handle_ping (struct GSC_KeyExchangeInfo *kx,
               &GSC_my_identity,
               sizeof (struct GNUNET_PeerIdentity)))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "We are not the intended target of the PING from peer `%s'\n",
-                GNUNET_i2s (&kx->peer));
+    if (GNUNET_CORE_KX_STATE_REKEY_SENT != kx->status)
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  "Decryption of PING from peer `%s' failed\n",
+                  GNUNET_i2s (&kx->peer));
+    else
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Decryption of PING from peer `%s' failed after rekey (harmless)\n",
+                  GNUNET_i2s (&kx->peer));
     GNUNET_break_op (0);
     return;
   }
@@ -1099,11 +1103,9 @@ GSC_KX_handle_ping (struct GSC_KeyExchangeInfo *kx,
  * (and we should prevent this by sending a PING).
  *
  * @param cls the `struct GSC_KeyExchangeInfo`
- * @param tc scheduler context (not used)
  */
 static void
-send_keep_alive (void *cls,
-                 const struct GNUNET_SCHEDULER_TaskContext *tc)
+send_keep_alive (void *cls)
 {
   struct GSC_KeyExchangeInfo *kx = cls;
   struct GNUNET_TIME_Relative retry;
@@ -1393,7 +1395,7 @@ GSC_KX_encrypt_and_transmit (struct GSC_KeyExchangeInfo *kx,
                              used - ENCRYPTED_HEADER_SIZE));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Encrypted %u bytes for %s\n",
-              used - ENCRYPTED_HEADER_SIZE,
+              (unsigned int) (used - ENCRYPTED_HEADER_SIZE),
               GNUNET_i2s (&kx->peer));
   derive_auth_key (&auth_key,
                   &kx->encrypt_key,
@@ -1515,7 +1517,7 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
     return;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Decrypted %u bytes from %s\n",
-              size - ENCRYPTED_HEADER_SIZE,
+              (unsigned int) (size - ENCRYPTED_HEADER_SIZE),
               GNUNET_i2s (&kx->peer));
   pt = (struct EncryptedMessage *) buf;
 
@@ -1693,11 +1695,9 @@ sign_ephemeral_key ()
  * Task run to trigger rekeying.
  *
  * @param cls closure, NULL
- * @param tc scheduler context
  */
 static void
-do_rekey (void *cls,
-         const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_rekey (void *cls)
 {
   struct GSC_KeyExchangeInfo *pos;