-bringing copyright tags up to FSF standard
[oweals/gnunet.git] / src / transport / test_plugin_transport.c
index 1b58c8c73aa1dc5170560254053955ad3b7ab2e3..bad07f7fb141f38e7d3bb3a2c68d7dabec5d50f1 100644 (file)
@@ -1,6 +1,6 @@
 /*
  This file is part of GNUnet.
- (C) 2009 Christian Grothoff (and other contributing authors)
Copyright (C) 2009 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
@@ -89,12 +89,12 @@ struct GNUNET_HELPER_Handle *suid_helper;
 /**
  * Timeout task
  */
-static GNUNET_SCHEDULER_TaskIdentifier timeout_endbadly;
+static struct GNUNET_SCHEDULER_Task * timeout_endbadly;
 
 /**
  * Timeout task
  */
-static GNUNET_SCHEDULER_TaskIdentifier timeout_wait;
+static struct GNUNET_SCHEDULER_Task * timeout_wait;
 
 /**
  * Library name
@@ -138,10 +138,10 @@ end ()
   int c = 0;
   ok = 0;
 
-  if (GNUNET_SCHEDULER_NO_TASK != timeout_endbadly)
+  if (NULL != timeout_endbadly)
   {
     GNUNET_SCHEDULER_cancel (timeout_endbadly);
-    timeout_endbadly = GNUNET_SCHEDULER_NO_TASK;
+    timeout_endbadly = NULL;
   }
   if (NULL != api)
     GNUNET_PLUGIN_unload (libname, api);
@@ -183,11 +183,11 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   struct AddressWrapper *w;
   int c = 0;
 
-  timeout_endbadly = GNUNET_SCHEDULER_NO_TASK;
-  if (GNUNET_SCHEDULER_NO_TASK != timeout_wait)
+  timeout_endbadly = NULL;
+  if (NULL != timeout_wait)
   {
     GNUNET_SCHEDULER_cancel (timeout_wait);
-    timeout_wait = GNUNET_SCHEDULER_NO_TASK;
+    timeout_wait = NULL;
   }
 
   if (pretty_printers_running > 0)
@@ -249,34 +249,36 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 static void
 wait_end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  timeout_wait = GNUNET_SCHEDULER_NO_TASK;
+  timeout_wait = NULL;
   if (0 == addresses_reported)
     GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
         "Plugin did not report any addresses, could not check address conversion functions\n");
   end ();
 }
 
+
 static void
 end_badly_now ()
 {
-  if (GNUNET_SCHEDULER_NO_TASK != timeout_wait)
+  if (NULL != timeout_wait)
   {
     GNUNET_SCHEDULER_cancel (timeout_wait);
-    timeout_wait = GNUNET_SCHEDULER_NO_TASK;
+    timeout_wait = NULL;
   }
-  if (GNUNET_SCHEDULER_NO_TASK != timeout_endbadly)
+  if (NULL != timeout_endbadly)
   {
     GNUNET_SCHEDULER_cancel (timeout_endbadly);
-    timeout_endbadly = GNUNET_SCHEDULER_NO_TASK;
+    timeout_endbadly = NULL;
   }
   timeout_endbadly = GNUNET_SCHEDULER_add_now (&end_badly, NULL );
 }
 
+
 static struct GNUNET_TIME_Relative
 env_receive (void *cls,
-    const struct GNUNET_HELLO_Address *address,
-    struct Session *session,
-    const struct GNUNET_MessageHeader *message)
+             const struct GNUNET_HELLO_Address *address,
+             struct Session *session,
+             const struct GNUNET_MessageHeader *message)
 {
   /* do nothing */
   return GNUNET_TIME_relative_get_zero_ ();
@@ -284,20 +286,22 @@ env_receive (void *cls,
 
 static int got_reply;
 
+
 /**
  * Take the given address and append it to the set of results sent back to
  * the client.
  *
- * @param cls the transmission context used ('struct GNUNET_SERVER_TransmitContext*')
- * @param buf text to transmit
+ * @param cls closure
+ * @param address the address to print
+ * @param res result code
  */
 static void
-address_pretty_printer_cb (void *cls, const char *buf)
+address_pretty_printer_cb (void *cls, const char *address, int res)
 {
-  if (NULL != buf)
+  if (NULL != address)
   {
     got_reply = GNUNET_YES;
-    GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Pretty address : `%s'\n", buf);
+    GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Pretty address : `%s'\n", address);
     pretty_printers_running--;
   }
   else
@@ -311,9 +315,11 @@ address_pretty_printer_cb (void *cls, const char *buf)
   }
 }
 
+
 static void
-env_notify_address (void *cls, int add_remove,
-    const struct GNUNET_HELLO_Address *address)
+env_notify_address (void *cls,
+                    int add_remove,
+                    const struct GNUNET_HELLO_Address *address)
 {
   struct AddressWrapper *w;
   struct AddressWrapper *wtmp;
@@ -342,7 +348,7 @@ env_notify_address (void *cls, int add_remove,
     GNUNET_CONTAINER_DLL_insert(head, tail, w);
     got_reply = GNUNET_NO;
     GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Testing: address_to_string \n");
-    w->addrstring = strdup (
+    w->addrstring = GNUNET_strdup (
         api->address_to_string (api, w->address->address,
             w->address->address_length));
     if (NULL == w->addrstring)
@@ -401,7 +407,8 @@ env_notify_address (void *cls, int add_remove,
     GNUNET_free(s2a);
 
     pretty_printers_running++;
-    api->address_pretty_printer (api->cls, address->transport_name, address->address, address->address_length, GNUNET_YES,
+    api->address_pretty_printer (api->cls, address->transport_name,
+        address->address, address->address_length, GNUNET_YES,
         GNUNET_TIME_UNIT_MINUTES, &address_pretty_printer_cb, w);
 
     if (GNUNET_OK != api->check_address (api->cls, w->address->address, w->address->address_length))
@@ -411,10 +418,10 @@ env_notify_address (void *cls, int add_remove,
       end_badly_now ();
       return;
     }
-    if (GNUNET_SCHEDULER_NO_TASK != timeout_wait)
+    if (NULL != timeout_wait)
     {
       GNUNET_SCHEDULER_cancel (timeout_wait);
-      timeout_wait = GNUNET_SCHEDULER_NO_TASK;
+      timeout_wait = NULL;
     }
 
     timeout_wait = GNUNET_SCHEDULER_add_delayed (WAIT, &wait_end, NULL );
@@ -459,21 +466,23 @@ env_notify_address (void *cls, int add_remove,
   }
 }
 
-static struct GNUNET_ATS_Information
-env_get_address_type (void *cls, const struct sockaddr *addr, size_t addrlen)
+
+static enum GNUNET_ATS_Network_Type
+env_get_address_type (void *cls,
+                      const struct sockaddr *addr,
+                      size_t addrlen)
 {
-  struct GNUNET_ATS_Information ats;
-  ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
-  ats.value = htonl (GNUNET_ATS_NET_LOOPBACK);
-  return ats;
+  return GNUNET_ATS_NET_LOOPBACK;
 }
 
+
 static const struct GNUNET_MessageHeader *
 env_get_our_hello ()
 {
   return (const struct GNUNET_MessageHeader *) hello;
 }
 
+
 static void
 env_session_end (void *cls,
                  const struct GNUNET_HELLO_Address *address,
@@ -482,15 +491,17 @@ env_session_end (void *cls,
 
 }
 
+
 static void
 env_update_metrics (void *cls,
-    const struct GNUNET_HELLO_Address *address,
-    struct Session *session,
-    const struct GNUNET_ATS_Information *ats,
-    uint32_t ats_count)
+                    const struct GNUNET_HELLO_Address *address,
+                    struct Session *session,
+                    const struct GNUNET_ATS_Information *ats,
+                    uint32_t ats_count)
 {
 }
 
+
 static void
 setup_plugin_environment ()
 {
@@ -507,13 +518,15 @@ setup_plugin_environment ()
   env.session_end = &env_session_end;
 }
 
+
 static int
 handle_helper_message (void *cls, void *client,
-    const struct GNUNET_MessageHeader *hdr)
+                       const struct GNUNET_MessageHeader *hdr)
 {
   return GNUNET_OK;
 }
 
+
 /**
  * Runs the test.
  *