use c99
[oweals/gnunet.git] / src / conversation / gnunet-service-conversation.c
index df8a56d7530c0c462769ebed426c480944f4110e..d12fbdc56606fd74a9cf82945b3841f47a122515 100644 (file)
@@ -1,6 +1,6 @@
 /*
   This file is part of GNUnet.
-  (C) 2013 Christian Grothoff (and other contributing authors)
+  Copyright (C) 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
@@ -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 conversation/gnunet-service-conversation.c
@@ -736,9 +736,10 @@ handle_client_call_message (void *cls,
   ring->target = msg->target;
   ring->source = my_identity;
   ring->expiration_time = GNUNET_TIME_absolute_hton (GNUNET_TIME_relative_to_absolute (RING_TIMEOUT));
-  GNUNET_CRYPTO_ecdsa_sign (&msg->caller_id,
-                            &ring->purpose,
-                            &ring->signature);
+  GNUNET_assert (GNUNET_OK ==
+                 GNUNET_CRYPTO_ecdsa_sign (&msg->caller_id,
+                                           &ring->purpose,
+                                           &ring->signature));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Sending RING message via cadet\n");
   GNUNET_MQ_send (ch->reliable_mq, e);
@@ -778,7 +779,9 @@ transmit_line_audio (void *cls,
   ch->audio_data = NULL;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Sending %u bytes of audio data from line %u to remote line %u via cadet\n",
-              ch->audio_size, ch->line->local_line, ch->remote_line);
+              (unsigned int) ch->audio_size,
+              ch->line->local_line,
+              ch->remote_line);
   return sizeof (struct CadetAudioMessage) + ch->audio_size;
 }
 
@@ -1045,7 +1048,8 @@ handle_cadet_hangup_message (void *cls,
  * @param channel_ctx the channel context, can be NULL
  *                    or point to the `struct Channel`
  * @param message the incoming message
- * @return #GNUNET_OK
+ * @return #GNUNET_OK if message was OK,
+ *         #GNUNET_SYSERR if message violated the protocol
  */
 static int
 handle_cadet_pickup_message (void *cls,
@@ -1075,7 +1079,7 @@ handle_cadet_pickup_message (void *cls,
   case CS_CALLEE_SHUTDOWN:
     GNUNET_break_op (0);
     destroy_line_cadet_channels (ch);
-    break;
+    return GNUNET_SYSERR;
   case CS_CALLER_CALLING:
     ch->status = CS_CALLER_CONNECTED;
     break;
@@ -1289,21 +1293,25 @@ handle_cadet_audio_message (void *cls,
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Received %u bytes of AUDIO data for non-existing line %u, dropping.\n",
-                  msize, ntohl (msg->remote_line));
+                  (unsigned int) msize,
+                  ntohl (msg->remote_line));
       return GNUNET_SYSERR;
     }
     if (NULL == ch)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Received %u bytes of AUDIO data for unknown sender.\n",
-                  msize);
+                  (unsigned int) msize);
       return GNUNET_SYSERR;
     }
     if ((GNUNET_YES == ch->suspended_local) || (GNUNET_YES == ch->suspended_remote))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Received %u bytes of AUDIO data on suspended channel CID %u:(%u:%u); dropping\n",
-                  msize, ch->cid, ch->remote_line, line->local_line);
+                  (unsigned int) msize,
+                  ch->cid,
+                  ch->remote_line,
+                  line->local_line);
       GNUNET_CADET_receive_done (channel);
       return GNUNET_OK;
     }
@@ -1313,7 +1321,10 @@ handle_cadet_audio_message (void *cls,
   GNUNET_CADET_receive_done (channel);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Forwarding %u bytes of AUDIO data to client CID %u:(%u:%u)\n",
-              msize, ch->cid, ch->remote_line, ch->line->local_line);
+              (unsigned int) msize,
+              ch->cid,
+              ch->remote_line,
+              ch->line->local_line);
   cam = (struct ClientAudioMessage *) buf;
   cam->header.size = htons (sizeof (buf));
   cam->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO);
@@ -1346,7 +1357,7 @@ inbound_channel (void *cls,
                 uint32_t port, enum GNUNET_CADET_ChannelOption options)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-             _("Received incoming channel on port %u\n"),
+             _("Received incoming Cadet channel on port %u\n"),
               (unsigned int) port);
   return NULL;
 }
@@ -1398,7 +1409,7 @@ inbound_end (void *cls,
   ch->channel_reliable = NULL;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Cadet channel destroyed by cadet in state %d\n",
+             "Cadet channel destroyed by Cadet in state %d\n",
               ch->status);
   hup.header.size = htons (sizeof (hup));
   hup.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP);
@@ -1445,7 +1456,7 @@ handle_client_disconnect (void *cls,
   line = GNUNET_SERVER_client_get_user_context (client, struct Line);
   if (NULL == line)
     return;
-  GNUNET_SERVER_client_set_user_context (client, (void *)NULL);
+  GNUNET_SERVER_client_set_user_context (client, NULL);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Client disconnected, closing line\n");
   GNUNET_CONTAINER_DLL_remove (lines_head,
@@ -1461,11 +1472,9 @@ handle_client_disconnect (void *cls,
  * Shutdown nicely
  *
  * @param cls closure, NULL
- * @param tc the task context
  */
 static void
-do_shutdown (void *cls,
-             const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_shutdown (void *cls)
 {
   struct Line *line;
   struct Channel *ch;
@@ -1477,7 +1486,7 @@ do_shutdown (void *cls,
     GNUNET_CONTAINER_DLL_remove (lines_head,
                                  lines_tail,
                                  line);
-    GNUNET_SERVER_client_set_user_context (line->client, (void *) NULL);
+    GNUNET_SERVER_client_set_user_context (line->client, NULL);
     GNUNET_free (line);
   }
   if (NULL != cadet)
@@ -1574,10 +1583,11 @@ run (void *cls,
   }
   nc = GNUNET_SERVER_notification_context_create (server, 16);
   GNUNET_SERVER_add_handlers (server, server_handlers);
-  GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
-                                &do_shutdown,
-                               NULL);
+  GNUNET_SERVER_disconnect_notify (server,
+                                  &handle_client_disconnect,
+                                  NULL);
+  GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+                                NULL);
 }