aboutsummaryrefslogtreecommitdiff
path: root/src/conversation/gnunet-service-conversation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/conversation/gnunet-service-conversation.c')
-rw-r--r--src/conversation/gnunet-service-conversation.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/src/conversation/gnunet-service-conversation.c b/src/conversation/gnunet-service-conversation.c
index 85bbc0481..d19be5318 100644
--- a/src/conversation/gnunet-service-conversation.c
+++ b/src/conversation/gnunet-service-conversation.c
@@ -1,17 +1,17 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2013 Christian Grothoff (and other contributing authors) 3 (C) 2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
@@ -105,7 +105,7 @@ struct Line
105 * Handle for the reliable tunnel (contol data) 105 * Handle for the reliable tunnel (contol data)
106 */ 106 */
107 struct GNUNET_MESH_Tunnel *tunnel_reliable; 107 struct GNUNET_MESH_Tunnel *tunnel_reliable;
108 108
109 /** 109 /**
110 * Handle for unreliable tunnel (audio data) 110 * Handle for unreliable tunnel (audio data)
111 */ 111 */
@@ -153,7 +153,7 @@ struct Line
153 153
154 /** 154 /**
155 * Current status of this line. 155 * Current status of this line.
156 */ 156 */
157 enum LineStatus status; 157 enum LineStatus status;
158 158
159}; 159};
@@ -374,7 +374,7 @@ mq_done_finish_caller_shutdown (void *cls)
374 case LS_CALLER_SHUTDOWN: 374 case LS_CALLER_SHUTDOWN:
375 destroy_line_mesh_tunnels (line); 375 destroy_line_mesh_tunnels (line);
376 break; 376 break;
377 } 377 }
378} 378}
379 379
380 380
@@ -536,7 +536,7 @@ transmit_line_audio (void *cls,
536{ 536{
537 struct Line *line = cls; 537 struct Line *line = cls;
538 struct MeshAudioMessage *mam = buf; 538 struct MeshAudioMessage *mam = buf;
539 539
540 line->unreliable_mth = NULL; 540 line->unreliable_mth = NULL;
541 if ( (NULL == buf) || 541 if ( (NULL == buf) ||
542 (size < sizeof (struct MeshAudioMessage) + line->audio_size) ) 542 (size < sizeof (struct MeshAudioMessage) + line->audio_size) )
@@ -553,7 +553,7 @@ transmit_line_audio (void *cls,
553 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 553 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
554 "Sending %u bytes of audio data via mesh\n", 554 "Sending %u bytes of audio data via mesh\n",
555 line->audio_size); 555 line->audio_size);
556 return sizeof (struct MeshAudioMessage) + line->audio_size; 556 return sizeof (struct MeshAudioMessage) + line->audio_size;
557} 557}
558 558
559 559
@@ -610,7 +610,7 @@ handle_client_audio_message (void *cls,
610 { 610 {
611 GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, 611 GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
612 _("Mesh audio channel not ready; audio data dropped\n")); 612 _("Mesh audio channel not ready; audio data dropped\n"));
613 GNUNET_SERVER_receive_done (client, GNUNET_OK); 613 GNUNET_SERVER_receive_done (client, GNUNET_OK);
614 return; 614 return;
615 } 615 }
616 if (NULL != line->unreliable_mth) 616 if (NULL != line->unreliable_mth)
@@ -632,7 +632,7 @@ handle_client_audio_message (void *cls,
632 line->unreliable_mth = GNUNET_MESH_notify_transmit_ready (line->tunnel_unreliable, 632 line->unreliable_mth = GNUNET_MESH_notify_transmit_ready (line->tunnel_unreliable,
633 GNUNET_NO, 633 GNUNET_NO,
634 GNUNET_TIME_UNIT_FOREVER_REL, 634 GNUNET_TIME_UNIT_FOREVER_REL,
635 sizeof (struct MeshAudioMessage) 635 sizeof (struct MeshAudioMessage)
636 + line->audio_size, 636 + line->audio_size,
637 &transmit_line_audio, 637 &transmit_line_audio,
638 line); 638 line);
@@ -641,7 +641,7 @@ handle_client_audio_message (void *cls,
641 641
642 642
643/** 643/**
644 * We are done signalling shutdown to the other peer. 644 * We are done signalling shutdown to the other peer.
645 * Destroy the tunnel. 645 * Destroy the tunnel.
646 * 646 *
647 * @param cls the `struct GNUNET_MESH_tunnel` to destroy 647 * @param cls the `struct GNUNET_MESH_tunnel` to destroy
@@ -650,7 +650,7 @@ static void
650mq_done_destroy_tunnel (void *cls) 650mq_done_destroy_tunnel (void *cls)
651{ 651{
652 struct GNUNET_MESH_Tunnel *tunnel = cls; 652 struct GNUNET_MESH_Tunnel *tunnel = cls;
653 653
654 GNUNET_MESH_tunnel_destroy (tunnel); 654 GNUNET_MESH_tunnel_destroy (tunnel);
655} 655}
656 656
@@ -675,7 +675,7 @@ handle_mesh_ring_message (void *cls,
675 struct GNUNET_MQ_Envelope *e; 675 struct GNUNET_MQ_Envelope *e;
676 struct MeshPhoneBusyMessage *busy; 676 struct MeshPhoneBusyMessage *busy;
677 struct ClientPhoneRingMessage cring; 677 struct ClientPhoneRingMessage cring;
678 678
679 msg = (const struct MeshPhoneRingMessage *) message; 679 msg = (const struct MeshPhoneRingMessage *) message;
680 if ( (msg->purpose.size != htonl (sizeof (struct GNUNET_PeerIdentity) * 2 + 680 if ( (msg->purpose.size != htonl (sizeof (struct GNUNET_PeerIdentity) * 2 +
681 sizeof (struct GNUNET_TIME_AbsoluteNBO) + 681 sizeof (struct GNUNET_TIME_AbsoluteNBO) +
@@ -690,11 +690,11 @@ handle_mesh_ring_message (void *cls,
690 GNUNET_break_op (0); 690 GNUNET_break_op (0);
691 return GNUNET_SYSERR; 691 return GNUNET_SYSERR;
692 } 692 }
693 for (line = lines_head; NULL != line; line = line->next) 693 for (line = lines_head; NULL != line; line = line->next)
694 if ( (line->local_line == ntohl (msg->remote_line)) && 694 if ( (line->local_line == ntohl (msg->remote_line)) &&
695 (LS_CALLEE_LISTEN == line->status) ) 695 (LS_CALLEE_LISTEN == line->status) )
696 break; 696 break;
697 if (NULL == line) 697 if (NULL == line)
698 { 698 {
699 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 699 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
700 _("No available phone for incoming call on line %u, sending BUSY signal\n"), 700 _("No available phone for incoming call on line %u, sending BUSY signal\n"),
@@ -748,7 +748,7 @@ handle_mesh_hangup_message (void *cls,
748 size_t len = ntohs (message->size) - sizeof (struct MeshPhoneHangupMessage); 748 size_t len = ntohs (message->size) - sizeof (struct MeshPhoneHangupMessage);
749 char buf[len + sizeof (struct ClientPhoneHangupMessage)]; 749 char buf[len + sizeof (struct ClientPhoneHangupMessage)];
750 struct ClientPhoneHangupMessage *hup; 750 struct ClientPhoneHangupMessage *hup;
751 751
752 msg = (const struct MeshPhoneHangupMessage *) message; 752 msg = (const struct MeshPhoneHangupMessage *) message;
753 len = ntohs (msg->header.size) - sizeof (struct MeshPhoneHangupMessage); 753 len = ntohs (msg->header.size) - sizeof (struct MeshPhoneHangupMessage);
754 reason = (const char *) &msg[1]; 754 reason = (const char *) &msg[1];
@@ -831,7 +831,7 @@ handle_mesh_pickup_message (void *cls,
831 size_t len = ntohs (message->size) - sizeof (struct MeshPhonePickupMessage); 831 size_t len = ntohs (message->size) - sizeof (struct MeshPhonePickupMessage);
832 char buf[len + sizeof (struct ClientPhonePickupMessage)]; 832 char buf[len + sizeof (struct ClientPhonePickupMessage)];
833 struct ClientPhonePickupMessage *pick; 833 struct ClientPhonePickupMessage *pick;
834 834
835 msg = (const struct MeshPhonePickupMessage *) message; 835 msg = (const struct MeshPhonePickupMessage *) message;
836 len = ntohs (msg->header.size) - sizeof (struct MeshPhonePickupMessage); 836 len = ntohs (msg->header.size) - sizeof (struct MeshPhonePickupMessage);
837 metadata = (const char *) &msg[1]; 837 metadata = (const char *) &msg[1];
@@ -895,7 +895,7 @@ handle_mesh_pickup_message (void *cls,
895 if (NULL == line->tunnel_unreliable) 895 if (NULL == line->tunnel_unreliable)
896 { 896 {
897 GNUNET_break (0); 897 GNUNET_break (0);
898 } 898 }
899 return GNUNET_OK; 899 return GNUNET_OK;
900} 900}
901 901
@@ -988,7 +988,7 @@ handle_mesh_audio_message (void *cls,
988 char buf[msize + sizeof (struct ClientAudioMessage)]; 988 char buf[msize + sizeof (struct ClientAudioMessage)];
989 struct ClientAudioMessage *cam; 989 struct ClientAudioMessage *cam;
990 const union GNUNET_MESH_TunnelInfo *info; 990 const union GNUNET_MESH_TunnelInfo *info;
991 991
992 msg = (const struct MeshAudioMessage *) message; 992 msg = (const struct MeshAudioMessage *) message;
993 if (NULL == line) 993 if (NULL == line)
994 { 994 {
@@ -1014,7 +1014,7 @@ handle_mesh_audio_message (void *cls,
1014 "Received AUDIO data for non-existing line %u, dropping.\n", 1014 "Received AUDIO data for non-existing line %u, dropping.\n",
1015 ntohl (msg->remote_line)); 1015 ntohl (msg->remote_line));
1016 return GNUNET_SYSERR; 1016 return GNUNET_SYSERR;
1017 } 1017 }
1018 line->tunnel_unreliable = tunnel; 1018 line->tunnel_unreliable = tunnel;
1019 *tunnel_ctx = line; 1019 *tunnel_ctx = line;
1020 } 1020 }
@@ -1047,11 +1047,11 @@ handle_mesh_audio_message (void *cls,
1047static void * 1047static void *
1048inbound_tunnel (void *cls, 1048inbound_tunnel (void *cls,
1049 struct GNUNET_MESH_Tunnel *tunnel, 1049 struct GNUNET_MESH_Tunnel *tunnel,
1050 const struct GNUNET_PeerIdentity *initiator, 1050 const struct GNUNET_PeerIdentity *initiator,
1051 uint32_t port) 1051 uint32_t port)
1052{ 1052{
1053 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1053 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1054 _("Received incoming tunnel on port %u\n"), 1054 _("Received incoming tunnel on port %u\n"),
1055 (unsigned int) port); 1055 (unsigned int) port);
1056 return NULL; 1056 return NULL;
1057} 1057}
@@ -1131,7 +1131,7 @@ inbound_end (void *cls,
1131 * @param client identification of the client 1131 * @param client identification of the client
1132 */ 1132 */
1133static void 1133static void
1134handle_client_disconnect (void *cls, 1134handle_client_disconnect (void *cls,
1135 struct GNUNET_SERVER_Client *client) 1135 struct GNUNET_SERVER_Client *client)
1136{ 1136{
1137 struct Line *line; 1137 struct Line *line;
@@ -1155,7 +1155,7 @@ handle_client_disconnect (void *cls,
1155 1155
1156/** 1156/**
1157 * Shutdown nicely 1157 * Shutdown nicely
1158 * 1158 *
1159 * @param cls closure, NULL 1159 * @param cls closure, NULL
1160 * @param tc the task context 1160 * @param tc the task context
1161 */ 1161 */
@@ -1184,7 +1184,7 @@ do_shutdown (void *cls,
1184 * @param c configuration 1184 * @param c configuration
1185 */ 1185 */
1186static void 1186static void
1187run (void *cls, 1187run (void *cls,
1188 struct GNUNET_SERVER_Handle *server, 1188 struct GNUNET_SERVER_Handle *server,
1189 const struct GNUNET_CONFIGURATION_Handle *c) 1189 const struct GNUNET_CONFIGURATION_Handle *c)
1190{ 1190{
@@ -1210,23 +1210,23 @@ run (void *cls,
1210 {&handle_mesh_ring_message, 1210 {&handle_mesh_ring_message,
1211 GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_RING, 1211 GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_RING,
1212 sizeof (struct MeshPhoneRingMessage)}, 1212 sizeof (struct MeshPhoneRingMessage)},
1213 {&handle_mesh_hangup_message, 1213 {&handle_mesh_hangup_message,
1214 GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_HANG_UP, 1214 GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_HANG_UP,
1215 0}, 1215 0},
1216 {&handle_mesh_pickup_message, 1216 {&handle_mesh_pickup_message,
1217 GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_PICK_UP, 1217 GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_PICK_UP,
1218 0}, 1218 0},
1219 {&handle_mesh_busy_message, 1219 {&handle_mesh_busy_message,
1220 GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_BUSY, 1220 GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_BUSY,
1221 sizeof (struct MeshPhoneBusyMessage)}, 1221 sizeof (struct MeshPhoneBusyMessage)},
1222 {&handle_mesh_audio_message, GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_AUDIO, 1222 {&handle_mesh_audio_message, GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_AUDIO,
1223 0}, 1223 0},
1224 {NULL, 0, 0} 1224 {NULL, 0, 0}
1225 }; 1225 };
1226 static uint32_t ports[] = { 1226 static uint32_t ports[] = {
1227 GNUNET_APPLICATION_TYPE_CONVERSATION_CONTROL, 1227 GNUNET_APPLICATION_TYPE_CONVERSATION_CONTROL,
1228 GNUNET_APPLICATION_TYPE_CONVERSATION_AUDIO, 1228 GNUNET_APPLICATION_TYPE_CONVERSATION_AUDIO,
1229 0 1229 0
1230 }; 1230 };
1231 1231
1232 cfg = c; 1232 cfg = c;
@@ -1236,8 +1236,8 @@ run (void *cls,
1236 mesh = GNUNET_MESH_connect (cfg, 1236 mesh = GNUNET_MESH_connect (cfg,
1237 NULL, 1237 NULL,
1238 &inbound_tunnel, 1238 &inbound_tunnel,
1239 &inbound_end, 1239 &inbound_end,
1240 mesh_handlers, 1240 mesh_handlers,
1241 ports); 1241 ports);
1242 1242
1243 if (NULL == mesh) 1243 if (NULL == mesh)
@@ -1249,7 +1249,7 @@ run (void *cls,
1249 nc = GNUNET_SERVER_notification_context_create (server, 16); 1249 nc = GNUNET_SERVER_notification_context_create (server, 16);
1250 GNUNET_SERVER_add_handlers (server, server_handlers); 1250 GNUNET_SERVER_add_handlers (server, server_handlers);
1251 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); 1251 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
1252 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 1252 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
1253 &do_shutdown, 1253 &do_shutdown,
1254 NULL); 1254 NULL);
1255} 1255}
@@ -1263,12 +1263,12 @@ run (void *cls,
1263 * @return 0 ok, 1 on error 1263 * @return 0 ok, 1 on error
1264 */ 1264 */
1265int 1265int
1266main (int argc, 1266main (int argc,
1267 char *const *argv) 1267 char *const *argv)
1268{ 1268{
1269 return (GNUNET_OK == 1269 return (GNUNET_OK ==
1270 GNUNET_SERVICE_run (argc, argv, 1270 GNUNET_SERVICE_run (argc, argv,
1271 "conversation", 1271 "conversation",
1272 GNUNET_SERVICE_OPTION_NONE, 1272 GNUNET_SERVICE_OPTION_NONE,
1273 &run, NULL)) ? 0 : 1; 1273 &run, NULL)) ? 0 : 1;
1274} 1274}