aboutsummaryrefslogtreecommitdiff
path: root/src/exit
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-17 19:06:15 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-17 19:06:15 +0000
commit9d077316ac3c6a18a4b13e90d7549188c2fe1f81 (patch)
treea6bc44ee81a35cf43ffe9c9968dfdc8de82711dd /src/exit
parent87509e6096da2f4c7a8359da338574f939d01f13 (diff)
downloadgnunet-9d077316ac3c6a18a4b13e90d7549188c2fe1f81.tar.gz
gnunet-9d077316ac3c6a18a4b13e90d7549188c2fe1f81.zip
-renaming TUN structs to follow namnig conventions
Diffstat (limited to 'src/exit')
-rw-r--r--src/exit/exit.h6
-rw-r--r--src/exit/gnunet-daemon-exit.c116
2 files changed, 61 insertions, 61 deletions
diff --git a/src/exit/exit.h b/src/exit/exit.h
index 2047ca113..3cd4292bd 100644
--- a/src/exit/exit.h
+++ b/src/exit/exit.h
@@ -53,7 +53,7 @@ struct GNUNET_EXIT_TcpServiceStartMessage
53 * Skeleton of the TCP header to send. Port numbers are to 53 * Skeleton of the TCP header to send. Port numbers are to
54 * be replaced and the checksum may be updated as necessary. 54 * be replaced and the checksum may be updated as necessary.
55 */ 55 */
56 struct tcp_packet tcp_header; 56 struct GNUNET_TUN_TcpHeader tcp_header;
57 57
58 /* followed by TCP payload */ 58 /* followed by TCP payload */
59}; 59};
@@ -79,7 +79,7 @@ struct GNUNET_EXIT_TcpInternetStartMessage
79 * Skeleton of the TCP header to send. Port numbers are to 79 * Skeleton of the TCP header to send. Port numbers are to
80 * be replaced and the checksum may be updated as necessary. 80 * be replaced and the checksum may be updated as necessary.
81 */ 81 */
82 struct tcp_packet tcp_header; 82 struct GNUNET_TUN_TcpHeader tcp_header;
83 83
84 /* followed by IP address of the destination; either 84 /* followed by IP address of the destination; either
85 'struct in_addr' or 'struct in6_addr', depending on af */ 85 'struct in_addr' or 'struct in6_addr', depending on af */
@@ -110,7 +110,7 @@ struct GNUNET_EXIT_TcpDataMessage
110 * Skeleton of the TCP header to send. Port numbers are to 110 * Skeleton of the TCP header to send. Port numbers are to
111 * be replaced and the checksum may be updated as necessary. (The destination port number should not be changed, as it contains the desired destination port.) 111 * be replaced and the checksum may be updated as necessary. (The destination port number should not be changed, as it contains the desired destination port.)
112 */ 112 */
113 struct tcp_packet tcp_header; 113 struct GNUNET_TUN_TcpHeader tcp_header;
114 114
115 /* followed by TCP payload */ 115 /* followed by TCP payload */
116}; 116};
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index 3dce69a3e..7df72fb02 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -595,7 +595,7 @@ send_packet_to_mesh_tunnel (struct GNUNET_MESH_Tunnel *mesh_tunnel,
595 * be the original destination address) 595 * be the original destination address)
596 */ 596 */
597static void 597static void
598udp_from_helper (const struct udp_packet *udp, 598udp_from_helper (const struct GNUNET_TUN_UdpHeader *udp,
599 size_t pktlen, 599 size_t pktlen,
600 int af, 600 int af,
601 const void *destination_ip, 601 const void *destination_ip,
@@ -617,7 +617,7 @@ udp_from_helper (const struct udp_packet *udp,
617 dbuf, sizeof (dbuf)), 617 dbuf, sizeof (dbuf)),
618 (unsigned int) ntohs (udp->dpt)); 618 (unsigned int) ntohs (udp->dpt));
619 } 619 }
620 if (pktlen < sizeof (struct udp_packet)) 620 if (pktlen < sizeof (struct GNUNET_TUN_UdpHeader))
621 { 621 {
622 /* blame kernel */ 622 /* blame kernel */
623 GNUNET_break (0); 623 GNUNET_break (0);
@@ -642,7 +642,7 @@ udp_from_helper (const struct udp_packet *udp,
642 return; 642 return;
643 } 643 }
644 send_packet_to_mesh_tunnel (state->tunnel, 644 send_packet_to_mesh_tunnel (state->tunnel,
645 &udp[1], pktlen - sizeof (struct udp_packet), 645 &udp[1], pktlen - sizeof (struct GNUNET_TUN_UdpHeader),
646 NULL, 646 NULL,
647 state->serv != NULL 647 state->serv != NULL
648 ? GNUNET_MESSAGE_TYPE_VPN_SERVICE_UDP_BACK 648 ? GNUNET_MESSAGE_TYPE_VPN_SERVICE_UDP_BACK
@@ -662,7 +662,7 @@ udp_from_helper (const struct udp_packet *udp,
662 * be the original destination address) 662 * be the original destination address)
663 */ 663 */
664static void 664static void
665tcp_from_helper (const struct tcp_packet *tcp, 665tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp,
666 size_t pktlen, 666 size_t pktlen,
667 int af, 667 int af,
668 const void *destination_ip, 668 const void *destination_ip,
@@ -670,7 +670,7 @@ tcp_from_helper (const struct tcp_packet *tcp,
670{ 670{
671 struct TunnelState *state; 671 struct TunnelState *state;
672 char buf[pktlen]; 672 char buf[pktlen];
673 struct tcp_packet *mtcp; 673 struct GNUNET_TUN_TcpHeader *mtcp;
674 674
675 { 675 {
676 char sbuf[INET6_ADDRSTRLEN]; 676 char sbuf[INET6_ADDRSTRLEN];
@@ -686,7 +686,7 @@ tcp_from_helper (const struct tcp_packet *tcp,
686 dbuf, sizeof (dbuf)), 686 dbuf, sizeof (dbuf)),
687 (unsigned int) ntohs (tcp->dpt)); 687 (unsigned int) ntohs (tcp->dpt));
688 } 688 }
689 if (pktlen < sizeof (struct tcp_packet)) 689 if (pktlen < sizeof (struct GNUNET_TUN_TcpHeader))
690 { 690 {
691 /* blame kernel */ 691 /* blame kernel */
692 GNUNET_break (0); 692 GNUNET_break (0);
@@ -708,7 +708,7 @@ tcp_from_helper (const struct tcp_packet *tcp,
708 /* mug port numbers and crc to avoid information leakage; 708 /* mug port numbers and crc to avoid information leakage;
709 sender will need to lookup the correct values anyway */ 709 sender will need to lookup the correct values anyway */
710 memcpy (buf, tcp, pktlen); 710 memcpy (buf, tcp, pktlen);
711 mtcp = (struct tcp_packet *) buf; 711 mtcp = (struct GNUNET_TUN_TcpHeader *) buf;
712 mtcp->spt = 0; 712 mtcp->spt = 0;
713 mtcp->dpt = 0; 713 mtcp->dpt = 0;
714 mtcp->crc = 0; 714 mtcp->crc = 0;
@@ -732,7 +732,7 @@ static void
732message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, 732message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
733 const struct GNUNET_MessageHeader *message) 733 const struct GNUNET_MessageHeader *message)
734{ 734{
735 const struct tun_header *pkt_tun; 735 const struct GNUNET_TUN_Layer2PacketHeader *pkt_tun;
736 size_t size; 736 size_t size;
737 737
738 GNUNET_STATISTICS_update (stats, 738 GNUNET_STATISTICS_update (stats,
@@ -744,7 +744,7 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
744 return; 744 return;
745 } 745 }
746 size = ntohs (message->size); 746 size = ntohs (message->size);
747 if (size < sizeof (struct tun_header) + sizeof (struct GNUNET_MessageHeader)) 747 if (size < sizeof (struct GNUNET_TUN_Layer2PacketHeader) + sizeof (struct GNUNET_MessageHeader))
748 { 748 {
749 GNUNET_break (0); 749 GNUNET_break (0);
750 return; 750 return;
@@ -752,38 +752,38 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
752 GNUNET_STATISTICS_update (stats, 752 GNUNET_STATISTICS_update (stats,
753 gettext_noop ("# Bytes received from TUN"), 753 gettext_noop ("# Bytes received from TUN"),
754 size, GNUNET_NO); 754 size, GNUNET_NO);
755 pkt_tun = (const struct tun_header *) &message[1]; 755 pkt_tun = (const struct GNUNET_TUN_Layer2PacketHeader *) &message[1];
756 size -= sizeof (struct tun_header) + sizeof (struct GNUNET_MessageHeader); 756 size -= sizeof (struct GNUNET_TUN_Layer2PacketHeader) + sizeof (struct GNUNET_MessageHeader);
757 switch (ntohs (pkt_tun->proto)) 757 switch (ntohs (pkt_tun->proto))
758 { 758 {
759 case ETH_P_IPV6: 759 case ETH_P_IPV6:
760 { 760 {
761 const struct ip6_header *pkt6; 761 const struct GNUNET_TUN_IPv6Header *pkt6;
762 762
763 if (size < sizeof (struct ip6_header)) 763 if (size < sizeof (struct GNUNET_TUN_IPv6Header))
764 { 764 {
765 /* Kernel to blame? */ 765 /* Kernel to blame? */
766 GNUNET_break (0); 766 GNUNET_break (0);
767 return; 767 return;
768 } 768 }
769 pkt6 = (struct ip6_header *) &pkt_tun[1]; 769 pkt6 = (struct GNUNET_TUN_IPv6Header *) &pkt_tun[1];
770 if (size != ntohs (pkt6->payload_length)) 770 if (size != ntohs (pkt6->payload_length))
771 { 771 {
772 /* Kernel to blame? */ 772 /* Kernel to blame? */
773 GNUNET_break (0); 773 GNUNET_break (0);
774 return; 774 return;
775 } 775 }
776 size -= sizeof (struct ip6_header); 776 size -= sizeof (struct GNUNET_TUN_IPv6Header);
777 switch (pkt6->next_header) 777 switch (pkt6->next_header)
778 { 778 {
779 case IPPROTO_UDP: 779 case IPPROTO_UDP:
780 udp_from_helper ((const struct udp_packet *) &pkt6[1], size, 780 udp_from_helper ((const struct GNUNET_TUN_UdpHeader *) &pkt6[1], size,
781 AF_INET6, 781 AF_INET6,
782 &pkt6->destination_address, 782 &pkt6->destination_address,
783 &pkt6->source_address); 783 &pkt6->source_address);
784 break; 784 break;
785 case IPPROTO_TCP: 785 case IPPROTO_TCP:
786 tcp_from_helper ((const struct tcp_packet *) &pkt6[1], size, 786 tcp_from_helper ((const struct GNUNET_TUN_TcpHeader *) &pkt6[1], size,
787 AF_INET6, 787 AF_INET6,
788 &pkt6->destination_address, 788 &pkt6->destination_address,
789 &pkt6->source_address); 789 &pkt6->source_address);
@@ -797,37 +797,37 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
797 break; 797 break;
798 case ETH_P_IPV4: 798 case ETH_P_IPV4:
799 { 799 {
800 const struct ip4_header *pkt4; 800 const struct GNUNET_TUN_IPv4Header *pkt4;
801 801
802 if (size < sizeof (struct ip4_header)) 802 if (size < sizeof (struct GNUNET_TUN_IPv4Header))
803 { 803 {
804 /* Kernel to blame? */ 804 /* Kernel to blame? */
805 GNUNET_break (0); 805 GNUNET_break (0);
806 return; 806 return;
807 } 807 }
808 pkt4 = (const struct ip4_header *) &pkt_tun[1]; 808 pkt4 = (const struct GNUNET_TUN_IPv4Header *) &pkt_tun[1];
809 if (size != ntohs (pkt4->total_length)) 809 if (size != ntohs (pkt4->total_length))
810 { 810 {
811 /* Kernel to blame? */ 811 /* Kernel to blame? */
812 GNUNET_break (0); 812 GNUNET_break (0);
813 return; 813 return;
814 } 814 }
815 if (pkt4->header_length * 4 != sizeof (struct ip4_header)) 815 if (pkt4->header_length * 4 != sizeof (struct GNUNET_TUN_IPv4Header))
816 { 816 {
817 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 817 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
818 _("IPv4 packet options received. Ignored.\n")); 818 _("IPv4 packet options received. Ignored.\n"));
819 return; 819 return;
820 } 820 }
821 size -= sizeof (struct ip4_header); 821 size -= sizeof (struct GNUNET_TUN_IPv4Header);
822 switch (pkt4->protocol) 822 switch (pkt4->protocol)
823 { 823 {
824 case IPPROTO_UDP: 824 case IPPROTO_UDP:
825 udp_from_helper ((const struct udp_packet *) &pkt4[1], size, 825 udp_from_helper ((const struct GNUNET_TUN_UdpHeader *) &pkt4[1], size,
826 AF_INET, 826 AF_INET,
827 &pkt4->destination_address, 827 &pkt4->destination_address,
828 &pkt4->source_address); 828 &pkt4->source_address);
829 case IPPROTO_TCP: 829 case IPPROTO_TCP:
830 tcp_from_helper ((const struct tcp_packet *) &pkt4[1], size, 830 tcp_from_helper ((const struct GNUNET_TUN_TcpHeader *) &pkt4[1], size,
831 AF_INET, 831 AF_INET,
832 &pkt4->destination_address, 832 &pkt4->destination_address,
833 &pkt4->source_address); 833 &pkt4->source_address);
@@ -1038,10 +1038,10 @@ setup_state_record (struct TunnelState *state)
1038static void 1038static void
1039prepare_ipv4_packet (const void *payload, size_t payload_length, 1039prepare_ipv4_packet (const void *payload, size_t payload_length,
1040 int protocol, 1040 int protocol,
1041 const struct tcp_packet *tcp_header, 1041 const struct GNUNET_TUN_TcpHeader *tcp_header,
1042 const struct SocketAddress *src_address, 1042 const struct SocketAddress *src_address,
1043 const struct SocketAddress *dst_address, 1043 const struct SocketAddress *dst_address,
1044 struct ip4_header *pkt4) 1044 struct GNUNET_TUN_IPv4Header *pkt4)
1045{ 1045{
1046 size_t len; 1046 size_t len;
1047 1047
@@ -1049,26 +1049,26 @@ prepare_ipv4_packet (const void *payload, size_t payload_length,
1049 switch (protocol) 1049 switch (protocol)
1050 { 1050 {
1051 case IPPROTO_UDP: 1051 case IPPROTO_UDP:
1052 len += sizeof (struct udp_packet); 1052 len += sizeof (struct GNUNET_TUN_UdpHeader);
1053 break; 1053 break;
1054 case IPPROTO_TCP: 1054 case IPPROTO_TCP:
1055 len += sizeof (struct tcp_packet); 1055 len += sizeof (struct GNUNET_TUN_TcpHeader);
1056 GNUNET_assert (NULL != tcp_header); 1056 GNUNET_assert (NULL != tcp_header);
1057 break; 1057 break;
1058 default: 1058 default:
1059 GNUNET_break (0); 1059 GNUNET_break (0);
1060 return; 1060 return;
1061 } 1061 }
1062 if (len + sizeof (struct ip4_header) > UINT16_MAX) 1062 if (len + sizeof (struct GNUNET_TUN_IPv4Header) > UINT16_MAX)
1063 { 1063 {
1064 GNUNET_break (0); 1064 GNUNET_break (0);
1065 return; 1065 return;
1066 } 1066 }
1067 1067
1068 pkt4->version = 4; 1068 pkt4->version = 4;
1069 pkt4->header_length = sizeof (struct ip4_header) / 4; 1069 pkt4->header_length = sizeof (struct GNUNET_TUN_IPv4Header) / 4;
1070 pkt4->diff_serv = 0; 1070 pkt4->diff_serv = 0;
1071 pkt4->total_length = htons ((uint16_t) (sizeof (struct ip4_header) + len)); 1071 pkt4->total_length = htons ((uint16_t) (sizeof (struct GNUNET_TUN_IPv4Header) + len));
1072 pkt4->identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1072 pkt4->identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
1073 UINT16_MAX + 1); 1073 UINT16_MAX + 1);
1074 pkt4->flags = 0; 1074 pkt4->flags = 0;
@@ -1078,13 +1078,13 @@ prepare_ipv4_packet (const void *payload, size_t payload_length,
1078 pkt4->checksum = 0; 1078 pkt4->checksum = 0;
1079 pkt4->destination_address = dst_address->address.ipv4; 1079 pkt4->destination_address = dst_address->address.ipv4;
1080 pkt4->source_address = src_address->address.ipv4; 1080 pkt4->source_address = src_address->address.ipv4;
1081 pkt4->checksum = GNUNET_CRYPTO_crc16_n (pkt4, sizeof (struct ip4_header)); 1081 pkt4->checksum = GNUNET_CRYPTO_crc16_n (pkt4, sizeof (struct GNUNET_TUN_IPv4Header));
1082 1082
1083 switch (protocol) 1083 switch (protocol)
1084 { 1084 {
1085 case IPPROTO_UDP: 1085 case IPPROTO_UDP:
1086 { 1086 {
1087 struct udp_packet *pkt4_udp = (struct udp_packet *) &pkt4[1]; 1087 struct GNUNET_TUN_UdpHeader *pkt4_udp = (struct GNUNET_TUN_UdpHeader *) &pkt4[1];
1088 1088
1089 pkt4_udp->spt = htons (src_address->port); 1089 pkt4_udp->spt = htons (src_address->port);
1090 pkt4_udp->dpt = htons (dst_address->port); 1090 pkt4_udp->dpt = htons (dst_address->port);
@@ -1095,9 +1095,9 @@ prepare_ipv4_packet (const void *payload, size_t payload_length,
1095 break; 1095 break;
1096 case IPPROTO_TCP: 1096 case IPPROTO_TCP:
1097 { 1097 {
1098 struct tcp_packet *pkt4_tcp = (struct tcp_packet *) &pkt4[1]; 1098 struct GNUNET_TUN_TcpHeader *pkt4_tcp = (struct GNUNET_TUN_TcpHeader *) &pkt4[1];
1099 1099
1100 memcpy (pkt4_tcp, tcp_header, sizeof (struct tcp_packet)); 1100 memcpy (pkt4_tcp, tcp_header, sizeof (struct GNUNET_TUN_TcpHeader));
1101 memcpy (&pkt4_tcp[1], payload, payload_length); 1101 memcpy (&pkt4_tcp[1], payload, payload_length);
1102 pkt4_tcp->spt = htons (src_address->port); 1102 pkt4_tcp->spt = htons (src_address->port);
1103 pkt4_tcp->dpt = htons (dst_address->port); 1103 pkt4_tcp->dpt = htons (dst_address->port);
@@ -1138,10 +1138,10 @@ prepare_ipv4_packet (const void *payload, size_t payload_length,
1138static void 1138static void
1139prepare_ipv6_packet (const void *payload, size_t payload_length, 1139prepare_ipv6_packet (const void *payload, size_t payload_length,
1140 int protocol, 1140 int protocol,
1141 const struct tcp_packet *tcp_header, 1141 const struct GNUNET_TUN_TcpHeader *tcp_header,
1142 const struct SocketAddress *src_address, 1142 const struct SocketAddress *src_address,
1143 const struct SocketAddress *dst_address, 1143 const struct SocketAddress *dst_address,
1144 struct ip6_header *pkt6) 1144 struct GNUNET_TUN_IPv6Header *pkt6)
1145{ 1145{
1146 size_t len; 1146 size_t len;
1147 1147
@@ -1149,11 +1149,11 @@ prepare_ipv6_packet (const void *payload, size_t payload_length,
1149 switch (protocol) 1149 switch (protocol)
1150 { 1150 {
1151 case IPPROTO_UDP: 1151 case IPPROTO_UDP:
1152 len += sizeof (struct udp_packet); 1152 len += sizeof (struct GNUNET_TUN_UdpHeader);
1153 break; 1153 break;
1154 case IPPROTO_TCP: 1154 case IPPROTO_TCP:
1155 /* tcp_header (with port/crc not set) must be part of payload! */ 1155 /* tcp_header (with port/crc not set) must be part of payload! */
1156 if (len < sizeof (struct tcp_packet)) 1156 if (len < sizeof (struct GNUNET_TUN_TcpHeader))
1157 { 1157 {
1158 GNUNET_break (0); 1158 GNUNET_break (0);
1159 return; 1159 return;
@@ -1171,7 +1171,7 @@ prepare_ipv6_packet (const void *payload, size_t payload_length,
1171 1171
1172 pkt6->version = 6; 1172 pkt6->version = 6;
1173 pkt6->next_header = protocol; 1173 pkt6->next_header = protocol;
1174 pkt6->payload_length = htons ((uint16_t) (len + sizeof (struct ip6_header))); 1174 pkt6->payload_length = htons ((uint16_t) (len + sizeof (struct GNUNET_TUN_IPv6Header)));
1175 pkt6->hop_limit = 255; 1175 pkt6->hop_limit = 255;
1176 pkt6->destination_address = dst_address->address.ipv6; 1176 pkt6->destination_address = dst_address->address.ipv6;
1177 pkt6->source_address = src_address->address.ipv6; 1177 pkt6->source_address = src_address->address.ipv6;
@@ -1180,7 +1180,7 @@ prepare_ipv6_packet (const void *payload, size_t payload_length,
1180 { 1180 {
1181 case IPPROTO_UDP: 1181 case IPPROTO_UDP:
1182 { 1182 {
1183 struct udp_packet *pkt6_udp = (struct udp_packet *) &pkt6[1]; 1183 struct GNUNET_TUN_UdpHeader *pkt6_udp = (struct GNUNET_TUN_UdpHeader *) &pkt6[1];
1184 1184
1185 memcpy (&pkt6[1], payload, payload_length); 1185 memcpy (&pkt6[1], payload, payload_length);
1186 pkt6_udp->crc = 0; 1186 pkt6_udp->crc = 0;
@@ -1202,7 +1202,7 @@ prepare_ipv6_packet (const void *payload, size_t payload_length,
1202 break; 1202 break;
1203 case IPPROTO_TCP: 1203 case IPPROTO_TCP:
1204 { 1204 {
1205 struct tcp_packet *pkt6_tcp = (struct tcp_packet *) pkt6; 1205 struct GNUNET_TUN_TcpHeader *pkt6_tcp = (struct GNUNET_TUN_TcpHeader *) pkt6;
1206 1206
1207 memcpy (pkt6_tcp, payload, payload_length); 1207 memcpy (pkt6_tcp, payload, payload_length);
1208 pkt6_tcp->crc = 0; 1208 pkt6_tcp->crc = 0;
@@ -1239,7 +1239,7 @@ prepare_ipv6_packet (const void *payload, size_t payload_length,
1239static void 1239static void
1240send_tcp_packet_via_tun (const struct SocketAddress *destination_address, 1240send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
1241 const struct SocketAddress *source_address, 1241 const struct SocketAddress *source_address,
1242 const struct tcp_packet *tcp_header, 1242 const struct GNUNET_TUN_TcpHeader *tcp_header,
1243 const void *payload, size_t payload_length) 1243 const void *payload, size_t payload_length)
1244{ 1244{
1245 size_t len; 1245 size_t len;
@@ -1250,14 +1250,14 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
1250 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1250 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1251 "Sending packet with %u bytes TCP payload via TUN\n", 1251 "Sending packet with %u bytes TCP payload via TUN\n",
1252 (unsigned int) payload_length); 1252 (unsigned int) payload_length);
1253 len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct tun_header); 1253 len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct GNUNET_TUN_Layer2PacketHeader);
1254 switch (source_address->af) 1254 switch (source_address->af)
1255 { 1255 {
1256 case AF_INET: 1256 case AF_INET:
1257 len += sizeof (struct ip4_header); 1257 len += sizeof (struct GNUNET_TUN_IPv4Header);
1258 break; 1258 break;
1259 case AF_INET6: 1259 case AF_INET6:
1260 len += sizeof (struct ip6_header); 1260 len += sizeof (struct GNUNET_TUN_IPv6Header);
1261 break; 1261 break;
1262 default: 1262 default:
1263 GNUNET_break (0); 1263 GNUNET_break (0);
@@ -1272,18 +1272,18 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
1272 { 1272 {
1273 char buf[len]; 1273 char buf[len];
1274 struct GNUNET_MessageHeader *hdr; 1274 struct GNUNET_MessageHeader *hdr;
1275 struct tun_header *tun; 1275 struct GNUNET_TUN_Layer2PacketHeader *tun;
1276 1276
1277 hdr= (struct GNUNET_MessageHeader *) buf; 1277 hdr= (struct GNUNET_MessageHeader *) buf;
1278 hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); 1278 hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER);
1279 hdr->size = htons (len); 1279 hdr->size = htons (len);
1280 tun = (struct tun_header*) &hdr[1]; 1280 tun = (struct GNUNET_TUN_Layer2PacketHeader*) &hdr[1];
1281 tun->flags = htons (0); 1281 tun->flags = htons (0);
1282 switch (source_address->af) 1282 switch (source_address->af)
1283 { 1283 {
1284 case AF_INET: 1284 case AF_INET:
1285 { 1285 {
1286 struct ip4_header * ipv4 = (struct ip4_header*) &tun[1]; 1286 struct GNUNET_TUN_IPv4Header * ipv4 = (struct GNUNET_TUN_IPv4Header*) &tun[1];
1287 1287
1288 tun->proto = htons (ETH_P_IPV4); 1288 tun->proto = htons (ETH_P_IPV4);
1289 prepare_ipv4_packet (payload, payload_length, 1289 prepare_ipv4_packet (payload, payload_length,
@@ -1296,7 +1296,7 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
1296 break; 1296 break;
1297 case AF_INET6: 1297 case AF_INET6:
1298 { 1298 {
1299 struct ip6_header * ipv6 = (struct ip6_header*) &tun[1]; 1299 struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1];
1300 1300
1301 tun->proto = htons (ETH_P_IPV6); 1301 tun->proto = htons (ETH_P_IPV6);
1302 prepare_ipv6_packet (payload, payload_length, 1302 prepare_ipv6_packet (payload, payload_length,
@@ -1589,20 +1589,20 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
1589 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1589 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1590 "Sending packet with %u bytes UDP payload via TUN\n", 1590 "Sending packet with %u bytes UDP payload via TUN\n",
1591 (unsigned int) payload_length); 1591 (unsigned int) payload_length);
1592 len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct tun_header); 1592 len = sizeof (struct GNUNET_MessageHeader) + sizeof (struct GNUNET_TUN_Layer2PacketHeader);
1593 switch (source_address->af) 1593 switch (source_address->af)
1594 { 1594 {
1595 case AF_INET: 1595 case AF_INET:
1596 len += sizeof (struct ip4_header); 1596 len += sizeof (struct GNUNET_TUN_IPv4Header);
1597 break; 1597 break;
1598 case AF_INET6: 1598 case AF_INET6:
1599 len += sizeof (struct ip6_header); 1599 len += sizeof (struct GNUNET_TUN_IPv6Header);
1600 break; 1600 break;
1601 default: 1601 default:
1602 GNUNET_break (0); 1602 GNUNET_break (0);
1603 return; 1603 return;
1604 } 1604 }
1605 len += sizeof (struct udp_packet); 1605 len += sizeof (struct GNUNET_TUN_UdpHeader);
1606 len += payload_length; 1606 len += payload_length;
1607 if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 1607 if (len >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
1608 { 1608 {
@@ -1612,18 +1612,18 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
1612 { 1612 {
1613 char buf[len]; 1613 char buf[len];
1614 struct GNUNET_MessageHeader *hdr; 1614 struct GNUNET_MessageHeader *hdr;
1615 struct tun_header *tun; 1615 struct GNUNET_TUN_Layer2PacketHeader *tun;
1616 1616
1617 hdr= (struct GNUNET_MessageHeader *) buf; 1617 hdr= (struct GNUNET_MessageHeader *) buf;
1618 hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); 1618 hdr->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER);
1619 hdr->size = htons (len); 1619 hdr->size = htons (len);
1620 tun = (struct tun_header*) &hdr[1]; 1620 tun = (struct GNUNET_TUN_Layer2PacketHeader*) &hdr[1];
1621 tun->flags = htons (0); 1621 tun->flags = htons (0);
1622 switch (source_address->af) 1622 switch (source_address->af)
1623 { 1623 {
1624 case AF_INET: 1624 case AF_INET:
1625 { 1625 {
1626 struct ip4_header * ipv4 = (struct ip4_header*) &tun[1]; 1626 struct GNUNET_TUN_IPv4Header * ipv4 = (struct GNUNET_TUN_IPv4Header*) &tun[1];
1627 1627
1628 tun->proto = htons (ETH_P_IPV4); 1628 tun->proto = htons (ETH_P_IPV4);
1629 prepare_ipv4_packet (payload, payload_length, 1629 prepare_ipv4_packet (payload, payload_length,
@@ -1636,7 +1636,7 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
1636 break; 1636 break;
1637 case AF_INET6: 1637 case AF_INET6:
1638 { 1638 {
1639 struct ip6_header * ipv6 = (struct ip6_header*) &tun[1]; 1639 struct GNUNET_TUN_IPv6Header * ipv6 = (struct GNUNET_TUN_IPv6Header*) &tun[1];
1640 1640
1641 tun->proto = htons (ETH_P_IPV6); 1641 tun->proto = htons (ETH_P_IPV6);
1642 prepare_ipv6_packet (payload, payload_length, 1642 prepare_ipv6_packet (payload, payload_length,