fixing compiler warnings
[oweals/gnunet.git] / src / transport / gnunet-service-transport.c
index 49a6d9abdd76abe85dd4d1e5a892c589b6b516d5..14eefdfb3f5f932304184056bdff8c4827527595 100644 (file)
@@ -1,6 +1,6 @@
 /*
  This file is part of GNUnet.
- Copyright (C) 2010-2015 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2010-2015 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
@@ -14,8 +14,8 @@
 
  You should have received a copy of the GNU General Public License
  along with GNUnet; see the file COPYING.  If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
  */
 /**
  * @file transport/gnunet-service-transport.c
 /**
  * Information we need for an asynchronous session kill.
  */
-struct SessionKiller
+struct GNUNET_ATS_SessionKiller
 {
   /**
    * Kept in a DLL.
    */
-  struct SessionKiller *next;
+  struct GNUNET_ATS_SessionKiller *next;
 
   /**
    * Kept in a DLL.
    */
-  struct SessionKiller *prev;
+  struct GNUNET_ATS_SessionKiller *prev;
 
   /**
    * Session to kill.
    */
-  struct Session *session;
+  struct GNUNET_ATS_Session *session;
 
   /**
    * Plugin for the session.
@@ -123,12 +123,12 @@ struct GNUNET_TIME_Relative hello_expiration;
 /**
  * Head of DLL of asynchronous tasks to kill sessions.
  */
-static struct SessionKiller *sk_head;
+static struct GNUNET_ATS_SessionKiller *sk_head;
 
 /**
  * Tail of DLL of asynchronous tasks to kill sessions.
  */
-static struct SessionKiller *sk_tail;
+static struct GNUNET_ATS_SessionKiller *sk_tail;
 
 /**
  * Interface scanner determines our LAN address range(s).
@@ -206,7 +206,7 @@ process_hello_update (void *cls,
  */
 static struct GNUNET_TIME_Relative
 process_payload (const struct GNUNET_HELLO_Address *address,
-                 struct Session *session,
+                 struct GNUNET_ATS_Session *session,
                  const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_TIME_Relative ret;
@@ -224,7 +224,7 @@ process_payload (const struct GNUNET_HELLO_Address *address,
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Discarded %u bytes type %u payload from peer `%s'\n",
-                msg_size,
+                (unsigned int) msg_size,
                 ntohs (message->type),
                 GNUNET_i2s (&address->peer));
     GNUNET_STATISTICS_update (GST_stats, gettext_noop
@@ -249,14 +249,12 @@ process_payload (const struct GNUNET_HELLO_Address *address,
 /**
  * Task to asynchronously terminate a session.
  *
- * @param cls the `struct SessionKiller` with the information for the kill
- * @param tc scheduler context
+ * @param cls the `struct GNUNET_ATS_SessionKiller` with the information for the kill
  */
 static void
-kill_session_task (void *cls,
-                   const struct GNUNET_SCHEDULER_TaskContext *tc)
+kill_session_task (void *cls)
 {
-  struct SessionKiller *sk = cls;
+  struct GNUNET_ATS_SessionKiller *sk = cls;
 
   sk->task = NULL;
   GNUNET_CONTAINER_DLL_remove (sk_head, sk_tail, sk);
@@ -274,10 +272,10 @@ kill_session_task (void *cls,
  */
 static void
 kill_session (const char *plugin_name,
-              struct Session *session)
+              struct GNUNET_ATS_Session *session)
 {
   struct GNUNET_TRANSPORT_PluginFunctions *plugin;
-  struct SessionKiller *sk;
+  struct GNUNET_ATS_SessionKiller *sk;
 
   for (sk = sk_head; NULL != sk; sk = sk->next)
     if (sk->session == session)
@@ -289,7 +287,7 @@ kill_session (const char *plugin_name,
     return;
   }
   /* need to issue disconnect asynchronously */
-  sk = GNUNET_new (struct SessionKiller);
+  sk = GNUNET_new (struct GNUNET_ATS_SessionKiller);
   sk->session = session;
   sk->plugin = plugin;
   sk->task = GNUNET_SCHEDULER_add_now (&kill_session_task, sk);
@@ -313,7 +311,7 @@ static void
 connect_bl_check_cont (void *cls,
                        const struct GNUNET_PeerIdentity *peer,
                       const struct GNUNET_HELLO_Address *address,
-                      struct Session *session,
+                      struct GNUNET_ATS_Session *session,
                        int result)
 {
   struct GNUNET_MessageHeader *msg = cls;
@@ -365,7 +363,7 @@ connect_bl_check_cont (void *cls,
 struct GNUNET_TIME_Relative
 GST_receive_callback (void *cls,
                       const struct GNUNET_HELLO_Address *address,
-                      struct Session *session,
+                      struct GNUNET_ATS_Session *session,
                       const struct GNUNET_MessageHeader *message)
 {
   const char *plugin_name = cls;
@@ -515,23 +513,31 @@ plugin_env_address_change_notification (void *cls,
   if (GNUNET_YES == add_remove)
   {
     addresses ++;
-    GNUNET_STATISTICS_update (cfg, "# transport addresses", 1, GNUNET_NO);
+    GNUNET_STATISTICS_update (cfg,
+                              "# transport addresses",
+                              1,
+                              GNUNET_NO);
   }
   else if (GNUNET_NO == add_remove)
   {
     if (0 == addresses)
+    {
       GNUNET_break (0);
+    }
     else
     {
       addresses --;
-      GNUNET_STATISTICS_update (cfg, "# transport addresses", -1, GNUNET_NO);
+      GNUNET_STATISTICS_update (cfg,
+                                "# transport addresses",
+                                -1,
+                                GNUNET_NO);
     }
   }
-
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Transport now has %u addresses to communicate\n",
               addresses);
-  GST_hello_modify_addresses (add_remove, address);
+  GST_hello_modify_addresses (add_remove,
+                              address);
 }
 
 
@@ -551,9 +557,9 @@ plugin_env_address_change_notification (void *cls,
 static void
 plugin_env_session_end (void *cls,
                         const struct GNUNET_HELLO_Address *address,
-                        struct Session *session)
+                        struct GNUNET_ATS_Session *session)
 {
-  struct SessionKiller *sk;
+  struct GNUNET_ATS_SessionKiller *sk;
 
   if (NULL == address)
   {
@@ -574,7 +580,8 @@ plugin_env_session_end (void *cls,
               GST_plugins_a2s (address));
 
   GST_neighbours_session_terminated (&address->peer, session);
-  GST_ats_del_session (address, session);
+  GST_ats_del_session (address,
+                       session);
   GST_blacklist_abort_matching (address, session);
 
   for (sk = sk_head; NULL != sk; sk = sk->next)
@@ -605,7 +612,7 @@ static void
 plugin_env_session_start_bl_check_cont (void *cls,
                                         const struct GNUNET_PeerIdentity *peer,
                                        const struct GNUNET_HELLO_Address *address,
-                                       struct Session *session,
+                                       struct GNUNET_ATS_Session *session,
                                         int result)
 {
   if (GNUNET_OK != result)
@@ -637,7 +644,7 @@ plugin_env_session_start_bl_check_cont (void *cls,
 static void
 plugin_env_session_start (void *cls,
                           const struct GNUNET_HELLO_Address *address,
-                          struct Session *session,
+                          struct GNUNET_ATS_Session *session,
                           enum GNUNET_ATS_Network_Type scope)
 {
   struct GNUNET_ATS_Properties prop;
@@ -704,7 +711,7 @@ static void
 ats_request_address_change (void *cls,
                             const struct GNUNET_PeerIdentity *peer,
                             const struct GNUNET_HELLO_Address *address,
-                            struct Session *session,
+                            struct GNUNET_ATS_Session *session,
                             struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
                             struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
 {
@@ -747,11 +754,9 @@ ats_request_address_change (void *cls,
  * and cancels pending validations.
  *
  * @param cls closure, unused
- * @param tc task context (unused)
  */
 static void
-shutdown_task (void *cls,
-               const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls)
 {
   GST_neighbours_stop ();
   GST_plugins_unload ();
@@ -843,9 +848,8 @@ run (void *cls,
              "My identity is `%4s'\n",
              GNUNET_i2s_full (&GST_my_identity));
 
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
-                                &shutdown_task,
-                                NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+                                NULL);
   if (NULL == GST_peerinfo)
   {
     GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
@@ -862,9 +866,9 @@ run (void *cls,
   {
     max_fd_rlimit = r_file.rlim_cur;
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-        "Maximum number of open files was: %u/%u\n",
-        r_file.rlim_cur,
-        r_file.rlim_max);
+                "Maximum number of open files was: %u/%u\n",
+                (unsigned int) r_file.rlim_cur,
+                (unsigned int) r_file.rlim_max);
   }
   max_fd_rlimit = (9 * max_fd_rlimit) / 10; /* Keep 10% for rest of transport */
 #endif