aboutsummaryrefslogtreecommitdiff
path: root/src/conversation/gnunet-service-conversation.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-11-14 13:55:12 +0000
committerBart Polot <bart@net.in.tum.de>2013-11-14 13:55:12 +0000
commitb7366f3d6a56d38d0269a33039f88de967e8c130 (patch)
treee299448a28e358c6549670a094b82f247925f7e2 /src/conversation/gnunet-service-conversation.c
parent6bde5e0c83d1fd344a26de64172ddce37920bb40 (diff)
downloadgnunet-b7366f3d6a56d38d0269a33039f88de967e8c130.tar.gz
gnunet-b7366f3d6a56d38d0269a33039f88de967e8c130.zip
Use encrypted MESH by default
Diffstat (limited to 'src/conversation/gnunet-service-conversation.c')
-rw-r--r--src/conversation/gnunet-service-conversation.c204
1 files changed, 102 insertions, 102 deletions
diff --git a/src/conversation/gnunet-service-conversation.c b/src/conversation/gnunet-service-conversation.c
index 054274e33..8e6e114df 100644
--- a/src/conversation/gnunet-service-conversation.c
+++ b/src/conversation/gnunet-service-conversation.c
@@ -86,8 +86,8 @@ enum LineStatus
86 86
87 87
88/** 88/**
89 * A line connects a local client with a mesh tunnel (or, if it is an 89 * A line connects a local client with a mesh channel (or, if it is an
90 * open line, is waiting for a mesh tunnel). 90 * open line, is waiting for a mesh channel).
91 */ 91 */
92struct Line 92struct Line
93{ 93{
@@ -102,14 +102,14 @@ struct Line
102 struct Line *prev; 102 struct Line *prev;
103 103
104 /** 104 /**
105 * Handle for the reliable tunnel (contol data) 105 * Handle for the reliable channel (contol data)
106 */ 106 */
107 struct GNUNET_MESH_Tunnel *tunnel_reliable; 107 struct GNUNET_MESH_Channel *channel_reliable;
108 108
109 /** 109 /**
110 * Handle for unreliable tunnel (audio data) 110 * Handle for unreliable channel (audio data)
111 */ 111 */
112 struct GNUNET_MESH_Tunnel *tunnel_unreliable; 112 struct GNUNET_MESH_Channel *channel_unreliable;
113 113
114 /** 114 /**
115 * Transmit handle for pending audio messages 115 * Transmit handle for pending audio messages
@@ -307,14 +307,14 @@ handle_client_pickup_message (void *cls,
307 307
308 308
309/** 309/**
310 * Destroy the mesh tunnels of a line. 310 * Destroy the mesh channels of a line.
311 * 311 *
312 * @param line line to shutdown tunnels of 312 * @param line line to shutdown channels of
313 */ 313 */
314static void 314static void
315destroy_line_mesh_tunnels (struct Line *line) 315destroy_line_mesh_channels (struct Line *line)
316{ 316{
317 struct GNUNET_MESH_Tunnel *t; 317 struct GNUNET_MESH_Channel *t;
318 318
319 if (NULL != line->reliable_mq) 319 if (NULL != line->reliable_mq)
320 { 320 {
@@ -326,15 +326,15 @@ destroy_line_mesh_tunnels (struct Line *line)
326 GNUNET_MESH_notify_transmit_ready_cancel (line->unreliable_mth); 326 GNUNET_MESH_notify_transmit_ready_cancel (line->unreliable_mth);
327 line->unreliable_mth = NULL; 327 line->unreliable_mth = NULL;
328 } 328 }
329 if (NULL != (t = line->tunnel_unreliable)) 329 if (NULL != (t = line->channel_unreliable))
330 { 330 {
331 line->tunnel_unreliable = NULL; 331 line->channel_unreliable = NULL;
332 GNUNET_MESH_tunnel_destroy (t); 332 GNUNET_MESH_channel_destroy (t);
333 } 333 }
334 if (NULL != (t = line->tunnel_reliable)) 334 if (NULL != (t = line->channel_reliable))
335 { 335 {
336 line->tunnel_reliable = NULL; 336 line->channel_reliable = NULL;
337 GNUNET_MESH_tunnel_destroy (t); 337 GNUNET_MESH_channel_destroy (t);
338 } 338 }
339} 339}
340 340
@@ -363,7 +363,7 @@ mq_done_finish_caller_shutdown (void *cls)
363 break; 363 break;
364 case LS_CALLEE_SHUTDOWN: 364 case LS_CALLEE_SHUTDOWN:
365 line->status = LS_CALLEE_LISTEN; 365 line->status = LS_CALLEE_LISTEN;
366 destroy_line_mesh_tunnels (line); 366 destroy_line_mesh_channels (line);
367 return; 367 return;
368 case LS_CALLER_CALLING: 368 case LS_CALLER_CALLING:
369 line->status = LS_CALLER_SHUTDOWN; 369 line->status = LS_CALLER_SHUTDOWN;
@@ -372,7 +372,7 @@ mq_done_finish_caller_shutdown (void *cls)
372 line->status = LS_CALLER_SHUTDOWN; 372 line->status = LS_CALLER_SHUTDOWN;
373 break; 373 break;
374 case LS_CALLER_SHUTDOWN: 374 case LS_CALLER_SHUTDOWN:
375 destroy_line_mesh_tunnels (line); 375 destroy_line_mesh_channels (line);
376 break; 376 break;
377 } 377 }
378} 378}
@@ -490,13 +490,13 @@ handle_client_call_message (void *cls,
490 line); 490 line);
491 line->remote_line = ntohl (msg->line); 491 line->remote_line = ntohl (msg->line);
492 line->status = LS_CALLER_CALLING; 492 line->status = LS_CALLER_CALLING;
493 line->tunnel_reliable = GNUNET_MESH_tunnel_create (mesh, 493 line->channel_reliable = GNUNET_MESH_channel_create (mesh,
494 line, 494 line,
495 &msg->target, 495 &msg->target,
496 GNUNET_APPLICATION_TYPE_CONVERSATION_CONTROL, 496 GNUNET_APPLICATION_TYPE_CONVERSATION_CONTROL,
497 GNUNET_NO, 497 GNUNET_NO,
498 GNUNET_YES); 498 GNUNET_YES);
499 line->reliable_mq = GNUNET_MESH_mq_create (line->tunnel_reliable); 499 line->reliable_mq = GNUNET_MESH_mq_create (line->channel_reliable);
500 line->local_line = local_line_cnt++; 500 line->local_line = local_line_cnt++;
501 e = GNUNET_MQ_msg (ring, GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_RING); 501 e = GNUNET_MQ_msg (ring, GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_RING);
502 ring->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING); 502 ring->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CONVERSATION_RING);
@@ -606,7 +606,7 @@ handle_client_audio_message (void *cls,
606 GNUNET_SERVER_receive_done (client, GNUNET_OK); 606 GNUNET_SERVER_receive_done (client, GNUNET_OK);
607 return; 607 return;
608 } 608 }
609 if (NULL == line->tunnel_unreliable) 609 if (NULL == line->channel_unreliable)
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"));
@@ -629,7 +629,7 @@ handle_client_audio_message (void *cls,
629 memcpy (line->audio_data, 629 memcpy (line->audio_data,
630 &msg[1], 630 &msg[1],
631 size); 631 size);
632 line->unreliable_mth = GNUNET_MESH_notify_transmit_ready (line->tunnel_unreliable, 632 line->unreliable_mth = GNUNET_MESH_notify_transmit_ready (line->channel_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)
@@ -642,16 +642,16 @@ handle_client_audio_message (void *cls,
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 channel.
646 * 646 *
647 * @param cls the `struct GNUNET_MESH_tunnel` to destroy 647 * @param cls the `struct GNUNET_MESH_channel` to destroy
648 */ 648 */
649static void 649static void
650mq_done_destroy_tunnel (void *cls) 650mq_done_destroy_channel (void *cls)
651{ 651{
652 struct GNUNET_MESH_Tunnel *tunnel = cls; 652 struct GNUNET_MESH_Channel *channel = cls;
653 653
654 GNUNET_MESH_tunnel_destroy (tunnel); 654 GNUNET_MESH_channel_destroy (channel);
655} 655}
656 656
657 657
@@ -659,15 +659,15 @@ mq_done_destroy_tunnel (void *cls)
659 * Function to handle a ring message incoming over mesh 659 * Function to handle a ring message incoming over mesh
660 * 660 *
661 * @param cls closure, NULL 661 * @param cls closure, NULL
662 * @param tunnel the tunnel over which the message arrived 662 * @param channel the channel over which the message arrived
663 * @param tunnel_ctx the tunnel context, can be NULL 663 * @param channel_ctx the channel context, can be NULL
664 * @param message the incoming message 664 * @param message the incoming message
665 * @return #GNUNET_OK 665 * @return #GNUNET_OK
666 */ 666 */
667static int 667static int
668handle_mesh_ring_message (void *cls, 668handle_mesh_ring_message (void *cls,
669 struct GNUNET_MESH_Tunnel *tunnel, 669 struct GNUNET_MESH_Channel *channel,
670 void **tunnel_ctx, 670 void **channel_ctx,
671 const struct GNUNET_MessageHeader *message) 671 const struct GNUNET_MessageHeader *message)
672{ 672{
673 const struct MeshPhoneRingMessage *msg; 673 const struct MeshPhoneRingMessage *msg;
@@ -701,17 +701,17 @@ handle_mesh_ring_message (void *cls,
701 ntohl (msg->remote_line)); 701 ntohl (msg->remote_line));
702 e = GNUNET_MQ_msg (busy, GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_BUSY); 702 e = GNUNET_MQ_msg (busy, GNUNET_MESSAGE_TYPE_CONVERSATION_MESH_PHONE_BUSY);
703 GNUNET_MQ_notify_sent (e, 703 GNUNET_MQ_notify_sent (e,
704 &mq_done_destroy_tunnel, 704 &mq_done_destroy_channel,
705 tunnel); 705 channel);
706 GNUNET_MQ_send (line->reliable_mq, e); 706 GNUNET_MQ_send (line->reliable_mq, e);
707 GNUNET_MESH_receive_done (tunnel); /* needed? */ 707 GNUNET_MESH_receive_done (channel); /* needed? */
708 return GNUNET_OK; 708 return GNUNET_OK;
709 } 709 }
710 line->status = LS_CALLEE_RINGING; 710 line->status = LS_CALLEE_RINGING;
711 line->remote_line = ntohl (msg->source_line); 711 line->remote_line = ntohl (msg->source_line);
712 line->tunnel_reliable = tunnel; 712 line->channel_reliable = channel;
713 line->reliable_mq = GNUNET_MESH_mq_create (line->tunnel_reliable); 713 line->reliable_mq = GNUNET_MESH_mq_create (line->channel_reliable);
714 *tunnel_ctx = line; 714 *channel_ctx = line;
715 cring.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING); 715 cring.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING);
716 cring.header.size = htons (sizeof (cring)); 716 cring.header.size = htons (sizeof (cring));
717 cring.reserved = htonl (0); 717 cring.reserved = htonl (0);
@@ -722,7 +722,7 @@ handle_mesh_ring_message (void *cls,
722 line->client, 722 line->client,
723 &cring.header, 723 &cring.header,
724 GNUNET_NO); 724 GNUNET_NO);
725 GNUNET_MESH_receive_done (tunnel); 725 GNUNET_MESH_receive_done (channel);
726 return GNUNET_OK; 726 return GNUNET_OK;
727} 727}
728 728
@@ -731,18 +731,18 @@ handle_mesh_ring_message (void *cls,
731 * Function to handle a hangup message incoming over mesh 731 * Function to handle a hangup message incoming over mesh
732 * 732 *
733 * @param cls closure, NULL 733 * @param cls closure, NULL
734 * @param tunnel the tunnel over which the message arrived 734 * @param channel the channel over which the message arrived
735 * @param tunnel_ctx the tunnel context, can be NULL 735 * @param channel_ctx the channel context, can be NULL
736 * @param message the incoming message 736 * @param message the incoming message
737 * @return #GNUNET_OK 737 * @return #GNUNET_OK
738 */ 738 */
739static int 739static int
740handle_mesh_hangup_message (void *cls, 740handle_mesh_hangup_message (void *cls,
741 struct GNUNET_MESH_Tunnel *tunnel, 741 struct GNUNET_MESH_Channel *channel,
742 void **tunnel_ctx, 742 void **channel_ctx,
743 const struct GNUNET_MessageHeader *message) 743 const struct GNUNET_MessageHeader *message)
744{ 744{
745 struct Line *line = *tunnel_ctx; 745 struct Line *line = *channel_ctx;
746 const struct MeshPhoneHangupMessage *msg; 746 const struct MeshPhoneHangupMessage *msg;
747 const char *reason; 747 const char *reason;
748 size_t len = ntohs (message->size) - sizeof (struct MeshPhoneHangupMessage); 748 size_t len = ntohs (message->size) - sizeof (struct MeshPhoneHangupMessage);
@@ -761,10 +761,10 @@ handle_mesh_hangup_message (void *cls,
761 if (NULL == line) 761 if (NULL == line)
762 { 762 {
763 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 763 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
764 "HANGUP message received for non-existing line, dropping tunnel.\n"); 764 "HANGUP message received for non-existing line, dropping channel.\n");
765 return GNUNET_SYSERR; 765 return GNUNET_SYSERR;
766 } 766 }
767 *tunnel_ctx = NULL; 767 *channel_ctx = NULL;
768 switch (line->status) 768 switch (line->status)
769 { 769 {
770 case LS_CALLEE_LISTEN: 770 case LS_CALLEE_LISTEN:
@@ -772,15 +772,15 @@ handle_mesh_hangup_message (void *cls,
772 return GNUNET_SYSERR; 772 return GNUNET_SYSERR;
773 case LS_CALLEE_RINGING: 773 case LS_CALLEE_RINGING:
774 line->status = LS_CALLEE_LISTEN; 774 line->status = LS_CALLEE_LISTEN;
775 destroy_line_mesh_tunnels (line); 775 destroy_line_mesh_channels (line);
776 break; 776 break;
777 case LS_CALLEE_CONNECTED: 777 case LS_CALLEE_CONNECTED:
778 line->status = LS_CALLEE_LISTEN; 778 line->status = LS_CALLEE_LISTEN;
779 destroy_line_mesh_tunnels (line); 779 destroy_line_mesh_channels (line);
780 break; 780 break;
781 case LS_CALLEE_SHUTDOWN: 781 case LS_CALLEE_SHUTDOWN:
782 line->status = LS_CALLEE_LISTEN; 782 line->status = LS_CALLEE_LISTEN;
783 destroy_line_mesh_tunnels (line); 783 destroy_line_mesh_channels (line);
784 return GNUNET_OK; 784 return GNUNET_OK;
785 case LS_CALLER_CALLING: 785 case LS_CALLER_CALLING:
786 line->status = LS_CALLER_SHUTDOWN; 786 line->status = LS_CALLER_SHUTDOWN;
@@ -805,7 +805,7 @@ handle_mesh_hangup_message (void *cls,
805 line->client, 805 line->client,
806 &hup->header, 806 &hup->header,
807 GNUNET_NO); 807 GNUNET_NO);
808 GNUNET_MESH_receive_done (tunnel); 808 GNUNET_MESH_receive_done (channel);
809 return GNUNET_OK; 809 return GNUNET_OK;
810} 810}
811 811
@@ -814,19 +814,19 @@ handle_mesh_hangup_message (void *cls,
814 * Function to handle a pickup message incoming over mesh 814 * Function to handle a pickup message incoming over mesh
815 * 815 *
816 * @param cls closure, NULL 816 * @param cls closure, NULL
817 * @param tunnel the tunnel over which the message arrived 817 * @param channel the channel over which the message arrived
818 * @param tunnel_ctx the tunnel context, can be NULL 818 * @param channel_ctx the channel context, can be NULL
819 * @param message the incoming message 819 * @param message the incoming message
820 * @return #GNUNET_OK 820 * @return #GNUNET_OK
821 */ 821 */
822static int 822static int
823handle_mesh_pickup_message (void *cls, 823handle_mesh_pickup_message (void *cls,
824 struct GNUNET_MESH_Tunnel *tunnel, 824 struct GNUNET_MESH_Channel *channel,
825 void **tunnel_ctx, 825 void **channel_ctx,
826 const struct GNUNET_MessageHeader *message) 826 const struct GNUNET_MessageHeader *message)
827{ 827{
828 const struct MeshPhonePickupMessage *msg; 828 const struct MeshPhonePickupMessage *msg;
829 struct Line *line = *tunnel_ctx; 829 struct Line *line = *channel_ctx;
830 const char *metadata; 830 const char *metadata;
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)];
@@ -844,10 +844,10 @@ handle_mesh_pickup_message (void *cls,
844 if (NULL == line) 844 if (NULL == line)
845 { 845 {
846 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 846 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
847 "PICKUP message received for non-existing line, dropping tunnel.\n"); 847 "PICKUP message received for non-existing line, dropping channel.\n");
848 return GNUNET_SYSERR; 848 return GNUNET_SYSERR;
849 } 849 }
850 GNUNET_MESH_receive_done (tunnel); 850 GNUNET_MESH_receive_done (channel);
851 switch (line->status) 851 switch (line->status)
852 { 852 {
853 case LS_CALLEE_LISTEN: 853 case LS_CALLEE_LISTEN:
@@ -856,13 +856,13 @@ handle_mesh_pickup_message (void *cls,
856 case LS_CALLEE_RINGING: 856 case LS_CALLEE_RINGING:
857 case LS_CALLEE_CONNECTED: 857 case LS_CALLEE_CONNECTED:
858 GNUNET_break_op (0); 858 GNUNET_break_op (0);
859 destroy_line_mesh_tunnels (line); 859 destroy_line_mesh_channels (line);
860 line->status = LS_CALLEE_LISTEN; 860 line->status = LS_CALLEE_LISTEN;
861 return GNUNET_SYSERR; 861 return GNUNET_SYSERR;
862 case LS_CALLEE_SHUTDOWN: 862 case LS_CALLEE_SHUTDOWN:
863 GNUNET_break_op (0); 863 GNUNET_break_op (0);
864 line->status = LS_CALLEE_LISTEN; 864 line->status = LS_CALLEE_LISTEN;
865 destroy_line_mesh_tunnels (line); 865 destroy_line_mesh_channels (line);
866 break; 866 break;
867 case LS_CALLER_CALLING: 867 case LS_CALLER_CALLING:
868 line->status = LS_CALLER_CONNECTED; 868 line->status = LS_CALLER_CONNECTED;
@@ -886,13 +886,13 @@ handle_mesh_pickup_message (void *cls,
886 line->client, 886 line->client,
887 &pick->header, 887 &pick->header,
888 GNUNET_NO); 888 GNUNET_NO);
889 line->tunnel_unreliable = GNUNET_MESH_tunnel_create (mesh, 889 line->channel_unreliable = GNUNET_MESH_channel_create (mesh,
890 line, 890 line,
891 &line->target, 891 &line->target,
892 GNUNET_APPLICATION_TYPE_CONVERSATION_AUDIO, 892 GNUNET_APPLICATION_TYPE_CONVERSATION_AUDIO,
893 GNUNET_YES, 893 GNUNET_YES,
894 GNUNET_NO); 894 GNUNET_NO);
895 if (NULL == line->tunnel_unreliable) 895 if (NULL == line->channel_unreliable)
896 { 896 {
897 GNUNET_break (0); 897 GNUNET_break (0);
898 } 898 }
@@ -904,30 +904,30 @@ handle_mesh_pickup_message (void *cls,
904 * Function to handle a busy message incoming over mesh 904 * Function to handle a busy message incoming over mesh
905 * 905 *
906 * @param cls closure, NULL 906 * @param cls closure, NULL
907 * @param tunnel the tunnel over which the message arrived 907 * @param channel the channel over which the message arrived
908 * @param tunnel_ctx the tunnel context, can be NULL 908 * @param channel_ctx the channel context, can be NULL
909 * @param message the incoming message 909 * @param message the incoming message
910 * @return #GNUNET_OK 910 * @return #GNUNET_OK
911 */ 911 */
912static int 912static int
913handle_mesh_busy_message (void *cls, 913handle_mesh_busy_message (void *cls,
914 struct GNUNET_MESH_Tunnel *tunnel, 914 struct GNUNET_MESH_Channel *channel,
915 void **tunnel_ctx, 915 void **channel_ctx,
916 const struct GNUNET_MessageHeader *message) 916 const struct GNUNET_MessageHeader *message)
917{ 917{
918 struct Line *line = *tunnel_ctx; 918 struct Line *line = *channel_ctx;
919 struct ClientPhoneBusyMessage busy; 919 struct ClientPhoneBusyMessage busy;
920 920
921 if (NULL == line) 921 if (NULL == line)
922 { 922 {
923 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 923 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
924 "HANGUP message received for non-existing line, dropping tunnel.\n"); 924 "HANGUP message received for non-existing line, dropping channel.\n");
925 return GNUNET_SYSERR; 925 return GNUNET_SYSERR;
926 } 926 }
927 busy.header.size = sizeof (busy); 927 busy.header.size = sizeof (busy);
928 busy.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_BUSY); 928 busy.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_BUSY);
929 GNUNET_MESH_receive_done (tunnel); 929 GNUNET_MESH_receive_done (channel);
930 *tunnel_ctx = NULL; 930 *channel_ctx = NULL;
931 switch (line->status) 931 switch (line->status)
932 { 932 {
933 case LS_CALLEE_LISTEN: 933 case LS_CALLEE_LISTEN:
@@ -970,43 +970,43 @@ handle_mesh_busy_message (void *cls,
970 * Function to handle an audio message incoming over mesh 970 * Function to handle an audio message incoming over mesh
971 * 971 *
972 * @param cls closure, NULL 972 * @param cls closure, NULL
973 * @param tunnel the tunnel over which the message arrived 973 * @param channel the channel over which the message arrived
974 * @param tunnel_ctx the tunnel context, can be NULL 974 * @param channel_ctx the channel context, can be NULL
975 * @param message the incoming message 975 * @param message the incoming message
976 * @return #GNUNET_OK 976 * @return #GNUNET_OK
977 */ 977 */
978static int 978static int
979handle_mesh_audio_message (void *cls, 979handle_mesh_audio_message (void *cls,
980 struct GNUNET_MESH_Tunnel *tunnel, 980 struct GNUNET_MESH_Channel *channel,
981 void **tunnel_ctx, 981 void **channel_ctx,
982 const struct GNUNET_MessageHeader *message) 982 const struct GNUNET_MessageHeader *message)
983{ 983{
984 const struct MeshAudioMessage *msg; 984 const struct MeshAudioMessage *msg;
985 struct Line *line = *tunnel_ctx; 985 struct Line *line = *channel_ctx;
986 struct GNUNET_PeerIdentity sender; 986 struct GNUNET_PeerIdentity sender;
987 size_t msize = ntohs (message->size) - sizeof (struct MeshAudioMessage); 987 size_t msize = ntohs (message->size) - sizeof (struct MeshAudioMessage);
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_ChannelInfo *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 {
995 info = GNUNET_MESH_tunnel_get_info (tunnel, 995 info = GNUNET_MESH_channel_get_info (channel,
996 GNUNET_MESH_OPTION_PEER); 996 GNUNET_MESH_OPTION_PEER);
997 if (NULL == info) 997 if (NULL == info)
998 { 998 {
999 GNUNET_break (0); 999 GNUNET_break (0);
1000 return GNUNET_OK; 1000 return GNUNET_OK;
1001 } 1001 }
1002 sender = info->peer; 1002 sender = *(info->peer);
1003 for (line = lines_head; NULL != line; line = line->next) 1003 for (line = lines_head; NULL != line; line = line->next)
1004 if ( (line->local_line == ntohl (msg->remote_line)) && 1004 if ( (line->local_line == ntohl (msg->remote_line)) &&
1005 (LS_CALLEE_CONNECTED == line->status) && 1005 (LS_CALLEE_CONNECTED == line->status) &&
1006 (0 == memcmp (&line->target, 1006 (0 == memcmp (&line->target,
1007 &sender, 1007 &sender,
1008 sizeof (struct GNUNET_PeerIdentity))) && 1008 sizeof (struct GNUNET_PeerIdentity))) &&
1009 (NULL == line->tunnel_unreliable) ) 1009 (NULL == line->channel_unreliable) )
1010 break; 1010 break;
1011 if (NULL == line) 1011 if (NULL == line)
1012 { 1012 {
@@ -1015,8 +1015,8 @@ handle_mesh_audio_message (void *cls,
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->channel_unreliable = channel;
1019 *tunnel_ctx = line; 1019 *channel_ctx = line;
1020 } 1020 }
1021 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1021 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1022 "Forwarding %u bytes of AUDIO data to client\n", 1022 "Forwarding %u bytes of AUDIO data to client\n",
@@ -1029,69 +1029,69 @@ handle_mesh_audio_message (void *cls,
1029 line->client, 1029 line->client,
1030 &cam->header, 1030 &cam->header,
1031 GNUNET_YES); 1031 GNUNET_YES);
1032 GNUNET_MESH_receive_done (tunnel); 1032 GNUNET_MESH_receive_done (channel);
1033 return GNUNET_OK; 1033 return GNUNET_OK;
1034} 1034}
1035 1035
1036 1036
1037/** 1037/**
1038 * Method called whenever another peer has added us to a tunnel 1038 * Method called whenever another peer has added us to a channel
1039 * the other peer initiated. 1039 * the other peer initiated.
1040 * 1040 *
1041 * @param cls closure 1041 * @param cls closure
1042 * @param tunnel new handle to the tunnel 1042 * @param channel new handle to the channel
1043 * @param initiator peer that started the tunnel 1043 * @param initiator peer that started the channel
1044 * @param port port 1044 * @param port port
1045 * @return initial tunnel context for the tunnel (can be NULL -- that's not an error) 1045 * @return initial channel context for the channel (can be NULL -- that's not an error)
1046 */ 1046 */
1047static void * 1047static void *
1048inbound_tunnel (void *cls, 1048inbound_channel (void *cls,
1049 struct GNUNET_MESH_Tunnel *tunnel, 1049 struct GNUNET_MESH_Channel *channel,
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 channel on port %u\n"),
1055 (unsigned int) port); 1055 (unsigned int) port);
1056 return NULL; 1056 return NULL;
1057} 1057}
1058 1058
1059 1059
1060/** 1060/**
1061 * Function called whenever an inbound tunnel is destroyed. Should clean up 1061 * Function called whenever an inbound channel is destroyed. Should clean up
1062 * any associated state. 1062 * any associated state.
1063 * 1063 *
1064 * @param cls closure (set from #GNUNET_MESH_connect) 1064 * @param cls closure (set from #GNUNET_MESH_connect)
1065 * @param tunnel connection to the other end (henceforth invalid) 1065 * @param channel connection to the other end (henceforth invalid)
1066 * @param tunnel_ctx place where local state associated 1066 * @param channel_ctx place where local state associated
1067 * with the tunnel is stored 1067 * with the channel is stored
1068 */ 1068 */
1069static void 1069static void
1070inbound_end (void *cls, 1070inbound_end (void *cls,
1071 const struct GNUNET_MESH_Tunnel *tunnel, 1071 const struct GNUNET_MESH_Channel *channel,
1072 void *tunnel_ctx) 1072 void *channel_ctx)
1073{ 1073{
1074 struct Line *line = tunnel_ctx; 1074 struct Line *line = channel_ctx;
1075 struct ClientPhoneHangupMessage hup; 1075 struct ClientPhoneHangupMessage hup;
1076 1076
1077 if (NULL == line) 1077 if (NULL == line)
1078 return; 1078 return;
1079 if (line->tunnel_unreliable == tunnel) 1079 if (line->channel_unreliable == channel)
1080 { 1080 {
1081 if (NULL != line->unreliable_mth) 1081 if (NULL != line->unreliable_mth)
1082 { 1082 {
1083 GNUNET_MESH_notify_transmit_ready_cancel (line->unreliable_mth); 1083 GNUNET_MESH_notify_transmit_ready_cancel (line->unreliable_mth);
1084 line->unreliable_mth = NULL; 1084 line->unreliable_mth = NULL;
1085 } 1085 }
1086 line->tunnel_unreliable = NULL; 1086 line->channel_unreliable = NULL;
1087 return; 1087 return;
1088 } 1088 }
1089 if (line->tunnel_reliable != tunnel) 1089 if (line->channel_reliable != channel)
1090 return; 1090 return;
1091 line->tunnel_reliable = NULL; 1091 line->channel_reliable = NULL;
1092 1092
1093 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1093 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1094 "Mesh tunnel destroyed by mesh\n"); 1094 "Mesh channel destroyed by mesh\n");
1095 hup.header.size = sizeof (hup); 1095 hup.header.size = sizeof (hup);
1096 hup.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP); 1096 hup.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP);
1097 switch (line->status) 1097 switch (line->status)
@@ -1120,7 +1120,7 @@ inbound_end (void *cls,
1120 case LS_CALLER_SHUTDOWN: 1120 case LS_CALLER_SHUTDOWN:
1121 break; 1121 break;
1122 } 1122 }
1123 destroy_line_mesh_tunnels (line); 1123 destroy_line_mesh_channels (line);
1124} 1124}
1125 1125
1126 1126
@@ -1147,7 +1147,7 @@ handle_client_disconnect (void *cls,
1147 GNUNET_CONTAINER_DLL_remove (lines_head, 1147 GNUNET_CONTAINER_DLL_remove (lines_head,
1148 lines_tail, 1148 lines_tail,
1149 line); 1149 line);
1150 destroy_line_mesh_tunnels (line); 1150 destroy_line_mesh_channels (line);
1151 GNUNET_free_non_null (line->audio_data); 1151 GNUNET_free_non_null (line->audio_data);
1152 GNUNET_free (line); 1152 GNUNET_free (line);
1153} 1153}
@@ -1235,7 +1235,7 @@ run (void *cls,
1235 &my_identity)); 1235 &my_identity));
1236 mesh = GNUNET_MESH_connect (cfg, 1236 mesh = GNUNET_MESH_connect (cfg,
1237 NULL, 1237 NULL,
1238 &inbound_tunnel, 1238 &inbound_channel,
1239 &inbound_end, 1239 &inbound_end,
1240 mesh_handlers, 1240 mesh_handlers,
1241 ports); 1241 ports);