aboutsummaryrefslogtreecommitdiff
path: root/src/vpn/gnunet-service-vpn.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-08-11 13:02:01 +0000
committerChristian Grothoff <christian@grothoff.org>2016-08-11 13:02:01 +0000
commit2a6e6e1654af25646b0f0812595ecf8e4319f643 (patch)
tree4ab2e8ba0283c540a1759f3ed3da346efd40ba54 /src/vpn/gnunet-service-vpn.c
parent666c8fa4c8e4ff13487dca37f26c26663adff579 (diff)
downloadgnunet-2a6e6e1654af25646b0f0812595ecf8e4319f643.tar.gz
gnunet-2a6e6e1654af25646b0f0812595ecf8e4319f643.zip
-convert vpn/exit/pt to use new CADET ports
Diffstat (limited to 'src/vpn/gnunet-service-vpn.c')
-rw-r--r--src/vpn/gnunet-service-vpn.c83
1 files changed, 47 insertions, 36 deletions
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c
index 812016205..785bf7be1 100644
--- a/src/vpn/gnunet-service-vpn.c
+++ b/src/vpn/gnunet-service-vpn.c
@@ -622,12 +622,15 @@ send_to_peer_notify_callback (void *cls, size_t size, void *buf)
622 ret = tnq->len; 622 ret = tnq->len;
623 GNUNET_free (tnq); 623 GNUNET_free (tnq);
624 if (NULL != (tnq = ts->tmq_head)) 624 if (NULL != (tnq = ts->tmq_head))
625 ts->th = GNUNET_CADET_notify_transmit_ready (ts->channel, 625 {
626 GNUNET_NO /* cork */, 626 if (NULL == ts->th)
627 GNUNET_TIME_UNIT_FOREVER_REL, 627 ts->th = GNUNET_CADET_notify_transmit_ready (ts->channel,
628 tnq->len, 628 GNUNET_NO /* cork */,
629 &send_to_peer_notify_callback, 629 GNUNET_TIME_UNIT_FOREVER_REL,
630 ts); 630 tnq->len,
631 &send_to_peer_notify_callback,
632 ts);
633 }
631 GNUNET_STATISTICS_update (stats, 634 GNUNET_STATISTICS_update (stats,
632 gettext_noop ("# Bytes given to cadet for transmission"), 635 gettext_noop ("# Bytes given to cadet for transmission"),
633 ret, GNUNET_NO); 636 ret, GNUNET_NO);
@@ -731,7 +734,7 @@ handle_regex_result (void *cls,
731 unsigned int put_path_length) 734 unsigned int put_path_length)
732{ 735{
733 struct ChannelState *ts = cls; 736 struct ChannelState *ts = cls;
734 unsigned int apptype; 737 struct GNUNET_HashCode port;
735 738
736 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 739 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
737 "Exit %s found for destination %s!\n", 740 "Exit %s found for destination %s!\n",
@@ -742,10 +745,16 @@ handle_regex_result (void *cls,
742 switch (ts->af) 745 switch (ts->af)
743 { 746 {
744 case AF_INET: 747 case AF_INET:
745 apptype = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY; 748 /* these must match the strings used in gnunet-daemon-exit */
749 GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_IPV4_GATEWAY,
750 strlen (GNUNET_APPLICATION_PORT_IPV4_GATEWAY),
751 &port);
746 break; 752 break;
747 case AF_INET6: 753 case AF_INET6:
748 apptype = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY; 754 /* these must match the strings used in gnunet-daemon-exit */
755 GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_IPV6_GATEWAY,
756 strlen (GNUNET_APPLICATION_PORT_IPV6_GATEWAY),
757 &port);
749 break; 758 break;
750 default: 759 default:
751 GNUNET_break (0); 760 GNUNET_break (0);
@@ -758,7 +767,7 @@ handle_regex_result (void *cls,
758 ts->channel = GNUNET_CADET_channel_create (cadet_handle, 767 ts->channel = GNUNET_CADET_channel_create (cadet_handle,
759 ts, 768 ts,
760 id, 769 id,
761 GC_u2h (apptype), 770 &port,
762 GNUNET_CADET_OPTION_DEFAULT); 771 GNUNET_CADET_OPTION_DEFAULT);
763} 772}
764 773
@@ -775,23 +784,11 @@ create_channel_to_destination (struct DestinationChannel *dt,
775 int client_af) 784 int client_af)
776{ 785{
777 struct ChannelState *ts; 786 struct ChannelState *ts;
778 unsigned int apptype;
779 787
780 GNUNET_STATISTICS_update (stats, 788 GNUNET_STATISTICS_update (stats,
781 gettext_noop ("# Cadet channels created"), 789 gettext_noop ("# Cadet channels created"),
782 1, GNUNET_NO); 790 1,
783 switch (client_af) 791 GNUNET_NO);
784 {
785 case AF_INET:
786 apptype = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY;
787 break;
788 case AF_INET6:
789 apptype = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY;
790 break;
791 default:
792 GNUNET_break (0);
793 return NULL;
794 }
795 ts = GNUNET_new (struct ChannelState); 792 ts = GNUNET_new (struct ChannelState);
796 ts->af = client_af; 793 ts->af = client_af;
797 ts->destination = *dt->destination; 794 ts->destination = *dt->destination;
@@ -801,12 +798,11 @@ create_channel_to_destination (struct DestinationChannel *dt,
801 ts->channel = GNUNET_CADET_channel_create (cadet_handle, 798 ts->channel = GNUNET_CADET_channel_create (cadet_handle,
802 ts, 799 ts,
803 &dt->destination->details.service_destination.target, 800 &dt->destination->details.service_destination.target,
804 GC_u2h (apptype), 801 &ts->destination.details.service_destination.service_descriptor,
805 GNUNET_CADET_OPTION_DEFAULT); 802 GNUNET_CADET_OPTION_DEFAULT);
806 if (NULL == ts->channel) 803 if (NULL == ts->channel)
807 { 804 {
808 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 805 GNUNET_break (0);
809 _("Failed to setup cadet channel!\n"));
810 GNUNET_free (ts); 806 GNUNET_free (ts);
811 return NULL; 807 return NULL;
812 } 808 }
@@ -1032,9 +1028,15 @@ route_packet (struct DestinationEntry *destination,
1032 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1028 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1033 "Routing %s packet from [%s]:%u -> [%s]:%u to destination [%s]:%u\n", 1029 "Routing %s packet from [%s]:%u -> [%s]:%u to destination [%s]:%u\n",
1034 (protocol == IPPROTO_TCP) ? "TCP" : "UDP", 1030 (protocol == IPPROTO_TCP) ? "TCP" : "UDP",
1035 inet_ntop (af, source_ip, sbuf, sizeof (sbuf)), 1031 inet_ntop (af,
1032 source_ip,
1033 sbuf,
1034 sizeof (sbuf)),
1036 source_port, 1035 source_port,
1037 inet_ntop (af, destination_ip, dbuf, sizeof (dbuf)), 1036 inet_ntop (af,
1037 destination_ip,
1038 dbuf,
1039 sizeof (dbuf)),
1038 destination_port, 1040 destination_port,
1039 inet_ntop (destination->details.exit_destination.af, 1041 inet_ntop (destination->details.exit_destination.af,
1040 &destination->details.exit_destination.ip, 1042 &destination->details.exit_destination.ip,
@@ -1054,9 +1056,15 @@ route_packet (struct DestinationEntry *destination,
1054 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1056 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1055 "Routing %s packet from [%s]:%u -> [%s]:%u to service %s at peer %s\n", 1057 "Routing %s packet from [%s]:%u -> [%s]:%u to service %s at peer %s\n",
1056 (protocol == IPPROTO_TCP) ? "TCP" : "UDP", 1058 (protocol == IPPROTO_TCP) ? "TCP" : "UDP",
1057 inet_ntop (af, source_ip, sbuf, sizeof (sbuf)), 1059 inet_ntop (af,
1060 source_ip,
1061 sbuf,
1062 sizeof (sbuf)),
1058 source_port, 1063 source_port,
1059 inet_ntop (af, destination_ip, dbuf, sizeof (dbuf)), 1064 inet_ntop (af,
1065 destination_ip,
1066 dbuf,
1067 sizeof (dbuf)),
1060 destination_port, 1068 destination_port,
1061 GNUNET_h2s (&destination->details.service_destination.service_descriptor), 1069 GNUNET_h2s (&destination->details.service_destination.service_descriptor),
1062 GNUNET_i2s (&destination->details.service_destination.target)); 1070 GNUNET_i2s (&destination->details.service_destination.target));
@@ -1163,8 +1171,8 @@ route_packet (struct DestinationEntry *destination,
1163 usm->destination_port = udp->destination_port; 1171 usm->destination_port = udp->destination_port;
1164 usm->service_descriptor = destination->details.service_destination.service_descriptor; 1172 usm->service_descriptor = destination->details.service_destination.service_descriptor;
1165 GNUNET_memcpy (&usm[1], 1173 GNUNET_memcpy (&usm[1],
1166 &udp[1], 1174 &udp[1],
1167 payload_length - sizeof (struct GNUNET_TUN_UdpHeader)); 1175 payload_length - sizeof (struct GNUNET_TUN_UdpHeader));
1168 } 1176 }
1169 else 1177 else
1170 { 1178 {
@@ -1233,8 +1241,8 @@ route_packet (struct DestinationEntry *destination,
1233 tsm->service_descriptor = destination->details.service_destination.service_descriptor; 1241 tsm->service_descriptor = destination->details.service_destination.service_descriptor;
1234 tsm->tcp_header = *tcp; 1242 tsm->tcp_header = *tcp;
1235 GNUNET_memcpy (&tsm[1], 1243 GNUNET_memcpy (&tsm[1],
1236 &tcp[1], 1244 &tcp[1],
1237 payload_length - sizeof (struct GNUNET_TUN_TcpHeader)); 1245 payload_length - sizeof (struct GNUNET_TUN_TcpHeader));
1238 } 1246 }
1239 else 1247 else
1240 { 1248 {
@@ -2760,7 +2768,10 @@ service_redirect_to_service (void *cls,
2760 2768
2761 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2769 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2762 "Allocated address %s for redirection to service %s on peer %s\n", 2770 "Allocated address %s for redirection to service %s on peer %s\n",
2763 inet_ntop (result_af, addr, sbuf, sizeof (sbuf)), 2771 inet_ntop (result_af,
2772 addr,
2773 sbuf,
2774 sizeof (sbuf)),
2764 GNUNET_h2s (&msg->service_descriptor), 2775 GNUNET_h2s (&msg->service_descriptor),
2765 GNUNET_i2s (&msg->target)); 2776 GNUNET_i2s (&msg->target));
2766 } 2777 }