-improve UDP logging
[oweals/gnunet.git] / src / core / test_core_api.c
index 184a640925649c450d4d5bae205b04173e8ffbc6..11fa47f2e648949be4ebf85ef0878c3b5f090ed6 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2009, 2010 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2009, 2010 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -22,7 +22,6 @@
  * @brief testcase for core_api.c
  */
 #include "platform.h"
-#include "gnunet_common.h"
 #include "gnunet_arm_service.h"
 #include "gnunet_core_service.h"
 #include "gnunet_getopt_lib.h"
@@ -49,9 +48,9 @@ static struct PeerContext p1;
 
 static struct PeerContext p2;
 
-static GNUNET_SCHEDULER_TaskIdentifier err_task;
+static struct GNUNET_SCHEDULER_Task * err_task;
 
-static GNUNET_SCHEDULER_TaskIdentifier con_task;
+static struct GNUNET_SCHEDULER_Task * con_task;
 
 static int ok;
 
@@ -89,10 +88,10 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   p1.th = NULL;
   GNUNET_TRANSPORT_disconnect (p2.th);
   p2.th = NULL;
-  if (GNUNET_SCHEDULER_NO_TASK != con_task)
+  if (NULL != con_task)
   {
     GNUNET_SCHEDULER_cancel (con_task);
-    con_task = GNUNET_SCHEDULER_NO_TASK;
+    con_task = NULL;
   }
   ok = 0;
 }
@@ -126,10 +125,10 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     GNUNET_TRANSPORT_disconnect (p2.th);
     p2.th = NULL;
   }
-  if (GNUNET_SCHEDULER_NO_TASK != con_task)
+  if (NULL != con_task)
   {
     GNUNET_SCHEDULER_cancel (con_task);
-    con_task = GNUNET_SCHEDULER_NO_TASK;
+    con_task = NULL;
   }
   ok = 42;
 }
@@ -163,10 +162,10 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer)
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Encrypted connection established to peer `%4s'\n",
               GNUNET_i2s (peer));
-  if (GNUNET_SCHEDULER_NO_TASK != con_task)
+  if (NULL != con_task)
   {
     GNUNET_SCHEDULER_cancel (con_task);
-    con_task = GNUNET_SCHEDULER_NO_TASK;
+    con_task = NULL;
   }
   pc->connect_status = 1;
   if (pc == &p1)
@@ -175,7 +174,8 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer)
                 "Asking core (1) for transmission to peer `%4s'\n",
                 GNUNET_i2s (&p2.id));
     if (NULL ==
-        GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_YES, 0,
+        GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_YES,
+                                           GNUNET_CORE_PRIO_BEST_EFFORT,
                                            GNUNET_TIME_relative_multiply
                                            (GNUNET_TIME_UNIT_SECONDS, 145),
                                            &p2.id,
@@ -250,7 +250,7 @@ connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
   {
-    con_task = GNUNET_SCHEDULER_NO_TASK;
+    con_task = NULL;
     return;
   }
   con_task =
@@ -264,16 +264,14 @@ connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
 
 static void
-init_notify (void *cls, struct GNUNET_CORE_Handle *server,
+init_notify (void *cls,
              const struct GNUNET_PeerIdentity *my_identity)
 {
   struct PeerContext *p = cls;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core connection to `%4s' established\n",
               GNUNET_i2s (my_identity));
-  GNUNET_assert (server != NULL);
   p->id = *my_identity;
-  p->ch = server;
   if (cls == &p1)
   {
     GNUNET_assert (ok == 2);
@@ -302,8 +300,8 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm");
   p->cfg = GNUNET_CONFIGURATION_create ();
   p->arm_proc =
-    GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, 
-                            NULL, NULL, 
+    GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+                            NULL, NULL, NULL,
                             binary,
                             "gnunet-service-arm",
                                "-c", cfgname, NULL);
@@ -337,7 +335,7 @@ run (void *cls, char *const *args, const char *cfgfile,
 static void
 stop_arm (struct PeerContext *p)
 {
-  if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
+  if (0 != GNUNET_OS_process_kill (p->arm_proc, GNUNET_TERM_SIG))
     GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
   if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK)
     GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");