diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-17 19:06:15 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-17 19:06:15 +0000 |
commit | 9d077316ac3c6a18a4b13e90d7549188c2fe1f81 (patch) | |
tree | a6bc44ee81a35cf43ffe9c9968dfdc8de82711dd /src/vpn | |
parent | 87509e6096da2f4c7a8359da338574f939d01f13 (diff) | |
download | gnunet-9d077316ac3c6a18a4b13e90d7549188c2fe1f81.tar.gz gnunet-9d077316ac3c6a18a4b13e90d7549188c2fe1f81.zip |
-renaming TUN structs to follow namnig conventions
Diffstat (limited to 'src/vpn')
-rw-r--r-- | src/vpn/gnunet-service-vpn.c | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c index 9c0fb1667..7aeabf457 100644 --- a/src/vpn/gnunet-service-vpn.c +++ b/src/vpn/gnunet-service-vpn.c | |||
@@ -880,8 +880,8 @@ route_packet (struct DestinationEntry *destination, | |||
880 | size_t alen; | 880 | size_t alen; |
881 | size_t mlen; | 881 | size_t mlen; |
882 | int is_new; | 882 | int is_new; |
883 | const struct udp_packet *udp; | 883 | const struct GNUNET_TUN_UdpHeader *udp; |
884 | const struct tcp_packet *tcp; | 884 | const struct GNUNET_TUN_TcpHeader *tcp; |
885 | uint16_t spt; | 885 | uint16_t spt; |
886 | uint16_t dpt; | 886 | uint16_t dpt; |
887 | 887 | ||
@@ -889,7 +889,7 @@ route_packet (struct DestinationEntry *destination, | |||
889 | { | 889 | { |
890 | case IPPROTO_UDP: | 890 | case IPPROTO_UDP: |
891 | { | 891 | { |
892 | if (payload_length < sizeof (struct udp_packet)) | 892 | if (payload_length < sizeof (struct GNUNET_TUN_UdpHeader)) |
893 | { | 893 | { |
894 | /* blame kernel? */ | 894 | /* blame kernel? */ |
895 | GNUNET_break (0); | 895 | GNUNET_break (0); |
@@ -909,7 +909,7 @@ route_packet (struct DestinationEntry *destination, | |||
909 | break; | 909 | break; |
910 | case IPPROTO_TCP: | 910 | case IPPROTO_TCP: |
911 | { | 911 | { |
912 | if (payload_length < sizeof (struct tcp_packet)) | 912 | if (payload_length < sizeof (struct GNUNET_TUN_TcpHeader)) |
913 | { | 913 | { |
914 | /* blame kernel? */ | 914 | /* blame kernel? */ |
915 | GNUNET_break (0); | 915 | GNUNET_break (0); |
@@ -1050,7 +1050,7 @@ route_packet (struct DestinationEntry *destination, | |||
1050 | struct GNUNET_EXIT_UdpServiceMessage *usm; | 1050 | struct GNUNET_EXIT_UdpServiceMessage *usm; |
1051 | 1051 | ||
1052 | mlen = sizeof (struct GNUNET_EXIT_UdpServiceMessage) + | 1052 | mlen = sizeof (struct GNUNET_EXIT_UdpServiceMessage) + |
1053 | payload_length - sizeof (struct udp_packet); | 1053 | payload_length - sizeof (struct GNUNET_TUN_UdpHeader); |
1054 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1054 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) |
1055 | { | 1055 | { |
1056 | GNUNET_break (0); | 1056 | GNUNET_break (0); |
@@ -1069,7 +1069,7 @@ route_packet (struct DestinationEntry *destination, | |||
1069 | usm->service_descriptor = destination->details.service_destination.service_descriptor; | 1069 | usm->service_descriptor = destination->details.service_destination.service_descriptor; |
1070 | memcpy (&usm[1], | 1070 | memcpy (&usm[1], |
1071 | &udp[1], | 1071 | &udp[1], |
1072 | payload_length - sizeof (struct udp_packet)); | 1072 | payload_length - sizeof (struct GNUNET_TUN_UdpHeader)); |
1073 | } | 1073 | } |
1074 | else | 1074 | else |
1075 | { | 1075 | { |
@@ -1079,7 +1079,7 @@ route_packet (struct DestinationEntry *destination, | |||
1079 | void *payload; | 1079 | void *payload; |
1080 | 1080 | ||
1081 | mlen = sizeof (struct GNUNET_EXIT_UdpInternetMessage) + | 1081 | mlen = sizeof (struct GNUNET_EXIT_UdpInternetMessage) + |
1082 | alen + payload_length - sizeof (struct udp_packet); | 1082 | alen + payload_length - sizeof (struct GNUNET_TUN_UdpHeader); |
1083 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1083 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) |
1084 | { | 1084 | { |
1085 | GNUNET_break (0); | 1085 | GNUNET_break (0); |
@@ -1112,7 +1112,7 @@ route_packet (struct DestinationEntry *destination, | |||
1112 | } | 1112 | } |
1113 | memcpy (payload, | 1113 | memcpy (payload, |
1114 | &udp[1], | 1114 | &udp[1], |
1115 | payload_length - sizeof (struct udp_packet)); | 1115 | payload_length - sizeof (struct GNUNET_TUN_UdpHeader)); |
1116 | } | 1116 | } |
1117 | break; | 1117 | break; |
1118 | case IPPROTO_TCP: | 1118 | case IPPROTO_TCP: |
@@ -1123,7 +1123,7 @@ route_packet (struct DestinationEntry *destination, | |||
1123 | struct GNUNET_EXIT_TcpServiceStartMessage *tsm; | 1123 | struct GNUNET_EXIT_TcpServiceStartMessage *tsm; |
1124 | 1124 | ||
1125 | mlen = sizeof (struct GNUNET_EXIT_TcpServiceStartMessage) + | 1125 | mlen = sizeof (struct GNUNET_EXIT_TcpServiceStartMessage) + |
1126 | payload_length - sizeof (struct tcp_packet); | 1126 | payload_length - sizeof (struct GNUNET_TUN_TcpHeader); |
1127 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1127 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) |
1128 | { | 1128 | { |
1129 | GNUNET_break (0); | 1129 | GNUNET_break (0); |
@@ -1140,7 +1140,7 @@ route_packet (struct DestinationEntry *destination, | |||
1140 | tsm->tcp_header = *tcp; | 1140 | tsm->tcp_header = *tcp; |
1141 | memcpy (&tsm[1], | 1141 | memcpy (&tsm[1], |
1142 | &tcp[1], | 1142 | &tcp[1], |
1143 | payload_length - sizeof (struct tcp_packet)); | 1143 | payload_length - sizeof (struct GNUNET_TUN_TcpHeader)); |
1144 | } | 1144 | } |
1145 | else | 1145 | else |
1146 | { | 1146 | { |
@@ -1150,7 +1150,7 @@ route_packet (struct DestinationEntry *destination, | |||
1150 | void *payload; | 1150 | void *payload; |
1151 | 1151 | ||
1152 | mlen = sizeof (struct GNUNET_EXIT_TcpInternetStartMessage) + | 1152 | mlen = sizeof (struct GNUNET_EXIT_TcpInternetStartMessage) + |
1153 | alen + payload_length - sizeof (struct tcp_packet); | 1153 | alen + payload_length - sizeof (struct GNUNET_TUN_TcpHeader); |
1154 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1154 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) |
1155 | { | 1155 | { |
1156 | GNUNET_break (0); | 1156 | GNUNET_break (0); |
@@ -1181,7 +1181,7 @@ route_packet (struct DestinationEntry *destination, | |||
1181 | } | 1181 | } |
1182 | memcpy (payload, | 1182 | memcpy (payload, |
1183 | &tcp[1], | 1183 | &tcp[1], |
1184 | payload_length - sizeof (struct tcp_packet)); | 1184 | payload_length - sizeof (struct GNUNET_TUN_TcpHeader)); |
1185 | } | 1185 | } |
1186 | } | 1186 | } |
1187 | else | 1187 | else |
@@ -1189,7 +1189,7 @@ route_packet (struct DestinationEntry *destination, | |||
1189 | struct GNUNET_EXIT_TcpDataMessage *tdm; | 1189 | struct GNUNET_EXIT_TcpDataMessage *tdm; |
1190 | 1190 | ||
1191 | mlen = sizeof (struct GNUNET_EXIT_TcpDataMessage) + | 1191 | mlen = sizeof (struct GNUNET_EXIT_TcpDataMessage) + |
1192 | alen + payload_length - sizeof (struct tcp_packet); | 1192 | alen + payload_length - sizeof (struct GNUNET_TUN_TcpHeader); |
1193 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | 1193 | if (mlen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) |
1194 | { | 1194 | { |
1195 | GNUNET_break (0); | 1195 | GNUNET_break (0); |
@@ -1205,7 +1205,7 @@ route_packet (struct DestinationEntry *destination, | |||
1205 | tdm->tcp_header = *tcp; | 1205 | tdm->tcp_header = *tcp; |
1206 | memcpy (&tdm[1], | 1206 | memcpy (&tdm[1], |
1207 | &tcp[1], | 1207 | &tcp[1], |
1208 | payload_length - sizeof (struct tcp_packet)); | 1208 | payload_length - sizeof (struct GNUNET_TUN_TcpHeader)); |
1209 | } | 1209 | } |
1210 | break; | 1210 | break; |
1211 | default: | 1211 | default: |
@@ -1231,7 +1231,7 @@ static void | |||
1231 | message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, | 1231 | message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, |
1232 | const struct GNUNET_MessageHeader *message) | 1232 | const struct GNUNET_MessageHeader *message) |
1233 | { | 1233 | { |
1234 | const struct tun_header *tun; | 1234 | const struct GNUNET_TUN_Layer2PacketHeader *tun; |
1235 | size_t mlen; | 1235 | size_t mlen; |
1236 | GNUNET_HashCode key; | 1236 | GNUNET_HashCode key; |
1237 | struct DestinationEntry *de; | 1237 | struct DestinationEntry *de; |
@@ -1241,26 +1241,26 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, | |||
1241 | 1, GNUNET_NO); | 1241 | 1, GNUNET_NO); |
1242 | mlen = ntohs (message->size); | 1242 | mlen = ntohs (message->size); |
1243 | if ( (ntohs (message->type) != GNUNET_MESSAGE_TYPE_VPN_HELPER) || | 1243 | if ( (ntohs (message->type) != GNUNET_MESSAGE_TYPE_VPN_HELPER) || |
1244 | (mlen < sizeof (struct GNUNET_MessageHeader) + sizeof (struct tun_header)) ) | 1244 | (mlen < sizeof (struct GNUNET_MessageHeader) + sizeof (struct GNUNET_TUN_Layer2PacketHeader)) ) |
1245 | { | 1245 | { |
1246 | GNUNET_break (0); | 1246 | GNUNET_break (0); |
1247 | return; | 1247 | return; |
1248 | } | 1248 | } |
1249 | tun = (const struct tun_header *) &message[1]; | 1249 | tun = (const struct GNUNET_TUN_Layer2PacketHeader *) &message[1]; |
1250 | mlen -= (sizeof (struct GNUNET_MessageHeader) + sizeof (struct tun_header)); | 1250 | mlen -= (sizeof (struct GNUNET_MessageHeader) + sizeof (struct GNUNET_TUN_Layer2PacketHeader)); |
1251 | switch (ntohs (tun->proto)) | 1251 | switch (ntohs (tun->proto)) |
1252 | { | 1252 | { |
1253 | case ETH_P_IPV6: | 1253 | case ETH_P_IPV6: |
1254 | { | 1254 | { |
1255 | const struct ip6_header *pkt6; | 1255 | const struct GNUNET_TUN_IPv6Header *pkt6; |
1256 | 1256 | ||
1257 | if (mlen < sizeof (struct ip6_header)) | 1257 | if (mlen < sizeof (struct GNUNET_TUN_IPv6Header)) |
1258 | { | 1258 | { |
1259 | /* blame kernel */ | 1259 | /* blame kernel */ |
1260 | GNUNET_break (0); | 1260 | GNUNET_break (0); |
1261 | return; | 1261 | return; |
1262 | } | 1262 | } |
1263 | pkt6 = (const struct ip6_header *) &tun[1]; | 1263 | pkt6 = (const struct GNUNET_TUN_IPv6Header *) &tun[1]; |
1264 | get_destination_key_from_ip (AF_INET6, | 1264 | get_destination_key_from_ip (AF_INET6, |
1265 | &pkt6->destination_address, | 1265 | &pkt6->destination_address, |
1266 | &key); | 1266 | &key); |
@@ -1288,20 +1288,20 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, | |||
1288 | &pkt6->source_address, | 1288 | &pkt6->source_address, |
1289 | &pkt6->destination_address, | 1289 | &pkt6->destination_address, |
1290 | &pkt6[1], | 1290 | &pkt6[1], |
1291 | mlen - sizeof (struct ip6_header)); | 1291 | mlen - sizeof (struct GNUNET_TUN_IPv6Header)); |
1292 | } | 1292 | } |
1293 | break; | 1293 | break; |
1294 | case ETH_P_IPV4: | 1294 | case ETH_P_IPV4: |
1295 | { | 1295 | { |
1296 | struct ip4_header *pkt4; | 1296 | struct GNUNET_TUN_IPv4Header *pkt4; |
1297 | 1297 | ||
1298 | if (mlen < sizeof (struct ip4_header)) | 1298 | if (mlen < sizeof (struct GNUNET_TUN_IPv4Header)) |
1299 | { | 1299 | { |
1300 | /* blame kernel */ | 1300 | /* blame kernel */ |
1301 | GNUNET_break (0); | 1301 | GNUNET_break (0); |
1302 | return; | 1302 | return; |
1303 | } | 1303 | } |
1304 | pkt4 = (struct ip4_header *) &tun[1]; | 1304 | pkt4 = (struct GNUNET_TUN_IPv4Header *) &tun[1]; |
1305 | get_destination_key_from_ip (AF_INET, | 1305 | get_destination_key_from_ip (AF_INET, |
1306 | &pkt4->destination_address, | 1306 | &pkt4->destination_address, |
1307 | &key); | 1307 | &key); |
@@ -1323,7 +1323,7 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, | |||
1323 | sizeof (buf))); | 1323 | sizeof (buf))); |
1324 | return; | 1324 | return; |
1325 | } | 1325 | } |
1326 | if (pkt4->header_length * 4 != sizeof (struct ip4_header)) | 1326 | if (pkt4->header_length * 4 != sizeof (struct GNUNET_TUN_IPv4Header)) |
1327 | { | 1327 | { |
1328 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1328 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1329 | _("Received IPv4 packet with options (dropping it)\n")); | 1329 | _("Received IPv4 packet with options (dropping it)\n")); |
@@ -1335,7 +1335,7 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED, | |||
1335 | &pkt4->source_address, | 1335 | &pkt4->source_address, |
1336 | &pkt4->destination_address, | 1336 | &pkt4->destination_address, |
1337 | &pkt4[1], | 1337 | &pkt4[1], |
1338 | mlen - sizeof (struct ip4_header)); | 1338 | mlen - sizeof (struct GNUNET_TUN_IPv4Header)); |
1339 | } | 1339 | } |
1340 | break; | 1340 | break; |
1341 | default: | 1341 | default: |
@@ -1407,26 +1407,26 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1407 | { | 1407 | { |
1408 | case AF_INET: | 1408 | case AF_INET: |
1409 | { | 1409 | { |
1410 | size_t size = sizeof (struct ip4_header) | 1410 | size_t size = sizeof (struct GNUNET_TUN_IPv4Header) |
1411 | + sizeof (struct udp_packet) | 1411 | + sizeof (struct GNUNET_TUN_UdpHeader) |
1412 | + sizeof (struct GNUNET_MessageHeader) + | 1412 | + sizeof (struct GNUNET_MessageHeader) + |
1413 | sizeof (struct tun_header) + | 1413 | sizeof (struct GNUNET_TUN_Layer2PacketHeader) + |
1414 | mlen; | 1414 | mlen; |
1415 | { | 1415 | { |
1416 | char buf[size]; | 1416 | char buf[size]; |
1417 | struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf; | 1417 | struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf; |
1418 | struct tun_header *tun = (struct tun_header*) &msg[1]; | 1418 | struct GNUNET_TUN_Layer2PacketHeader *tun = (struct GNUNET_TUN_Layer2PacketHeader*) &msg[1]; |
1419 | struct ip4_header *ipv4 = (struct ip4_header *) &tun[1]; | 1419 | struct GNUNET_TUN_IPv4Header *ipv4 = (struct GNUNET_TUN_IPv4Header *) &tun[1]; |
1420 | struct udp_packet *udp = (struct udp_packet *) &ipv4[1]; | 1420 | struct GNUNET_TUN_UdpHeader *udp = (struct GNUNET_TUN_UdpHeader *) &ipv4[1]; |
1421 | msg->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); | 1421 | msg->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); |
1422 | msg->size = htons (size); | 1422 | msg->size = htons (size); |
1423 | tun->flags = htons (0); | 1423 | tun->flags = htons (0); |
1424 | tun->proto = htons (ETH_P_IPV4); | 1424 | tun->proto = htons (ETH_P_IPV4); |
1425 | ipv4->version = 4; | 1425 | ipv4->version = 4; |
1426 | ipv4->header_length = sizeof (struct ip4_header) / 4; | 1426 | ipv4->header_length = sizeof (struct GNUNET_TUN_IPv4Header) / 4; |
1427 | ipv4->diff_serv = 0; | 1427 | ipv4->diff_serv = 0; |
1428 | ipv4->total_length = htons (sizeof (struct ip4_header) + | 1428 | ipv4->total_length = htons (sizeof (struct GNUNET_TUN_IPv4Header) + |
1429 | sizeof (struct udp_packet) + | 1429 | sizeof (struct GNUNET_TUN_UdpHeader) + |
1430 | mlen); | 1430 | mlen); |
1431 | ipv4->identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 1431 | ipv4->identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
1432 | UINT16_MAX + 1); | 1432 | UINT16_MAX + 1); |
@@ -1438,7 +1438,7 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1438 | ipv4->source_address = ts->destination_ip.v4; | 1438 | ipv4->source_address = ts->destination_ip.v4; |
1439 | ipv4->destination_address = ts->source_ip.v4; | 1439 | ipv4->destination_address = ts->source_ip.v4; |
1440 | ipv4->checksum = | 1440 | ipv4->checksum = |
1441 | GNUNET_CRYPTO_crc16_n (ipv4, sizeof (struct ip4_header)); | 1441 | GNUNET_CRYPTO_crc16_n (ipv4, sizeof (struct GNUNET_TUN_IPv4Header)); |
1442 | if (0 == ntohs (reply->source_port)) | 1442 | if (0 == ntohs (reply->source_port)) |
1443 | udp->spt = htons (ts->destination_port); | 1443 | udp->spt = htons (ts->destination_port); |
1444 | else | 1444 | else |
@@ -1447,7 +1447,7 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1447 | udp->dpt = htons (ts->source_port); | 1447 | udp->dpt = htons (ts->source_port); |
1448 | else | 1448 | else |
1449 | udp->dpt = reply->destination_port; | 1449 | udp->dpt = reply->destination_port; |
1450 | udp->len = htons (mlen + sizeof (struct udp_packet)); | 1450 | udp->len = htons (mlen + sizeof (struct GNUNET_TUN_UdpHeader)); |
1451 | udp->crc = 0; // FIXME: optional, but we might want to calculate this one anyway | 1451 | udp->crc = 0; // FIXME: optional, but we might want to calculate this one anyway |
1452 | memcpy (&udp[1], | 1452 | memcpy (&udp[1], |
1453 | &reply[1], | 1453 | &reply[1], |
@@ -1461,17 +1461,17 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1461 | break; | 1461 | break; |
1462 | case AF_INET6: | 1462 | case AF_INET6: |
1463 | { | 1463 | { |
1464 | size_t size = sizeof (struct ip6_header) | 1464 | size_t size = sizeof (struct GNUNET_TUN_IPv6Header) |
1465 | + sizeof (struct udp_packet) | 1465 | + sizeof (struct GNUNET_TUN_UdpHeader) |
1466 | + sizeof (struct GNUNET_MessageHeader) + | 1466 | + sizeof (struct GNUNET_MessageHeader) + |
1467 | sizeof (struct tun_header) + | 1467 | sizeof (struct GNUNET_TUN_Layer2PacketHeader) + |
1468 | mlen; | 1468 | mlen; |
1469 | { | 1469 | { |
1470 | char buf[size]; | 1470 | char buf[size]; |
1471 | struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf; | 1471 | struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf; |
1472 | struct tun_header *tun = (struct tun_header*) &msg[1]; | 1472 | struct GNUNET_TUN_Layer2PacketHeader *tun = (struct GNUNET_TUN_Layer2PacketHeader*) &msg[1]; |
1473 | struct ip6_header *ipv6 = (struct ip6_header *) &tun[1]; | 1473 | struct GNUNET_TUN_IPv6Header *ipv6 = (struct GNUNET_TUN_IPv6Header *) &tun[1]; |
1474 | struct udp_packet *udp = (struct udp_packet *) &ipv6[1]; | 1474 | struct GNUNET_TUN_UdpHeader *udp = (struct GNUNET_TUN_UdpHeader *) &ipv6[1]; |
1475 | msg->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); | 1475 | msg->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); |
1476 | msg->size = htons (size); | 1476 | msg->size = htons (size); |
1477 | tun->flags = htons (0); | 1477 | tun->flags = htons (0); |
@@ -1480,7 +1480,7 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1480 | ipv6->version = 6; | 1480 | ipv6->version = 6; |
1481 | ipv6->traffic_class_l = 0; | 1481 | ipv6->traffic_class_l = 0; |
1482 | ipv6->flow_label = 0; | 1482 | ipv6->flow_label = 0; |
1483 | ipv6->payload_length = htons (sizeof (struct udp_packet) + sizeof (struct ip6_header) + mlen); | 1483 | ipv6->payload_length = htons (sizeof (struct GNUNET_TUN_UdpHeader) + sizeof (struct GNUNET_TUN_IPv6Header) + mlen); |
1484 | ipv6->next_header = IPPROTO_UDP; | 1484 | ipv6->next_header = IPPROTO_UDP; |
1485 | ipv6->hop_limit = 255; | 1485 | ipv6->hop_limit = 255; |
1486 | ipv6->source_address = ts->destination_ip.v6; | 1486 | ipv6->source_address = ts->destination_ip.v6; |
@@ -1493,7 +1493,7 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1493 | udp->dpt = htons (ts->source_port); | 1493 | udp->dpt = htons (ts->source_port); |
1494 | else | 1494 | else |
1495 | udp->dpt = reply->destination_port; | 1495 | udp->dpt = reply->destination_port; |
1496 | udp->len = htons (mlen + sizeof (struct udp_packet)); | 1496 | udp->len = htons (mlen + sizeof (struct GNUNET_TUN_UdpHeader)); |
1497 | udp->crc = 0; | 1497 | udp->crc = 0; |
1498 | memcpy (&udp[1], | 1498 | memcpy (&udp[1], |
1499 | &reply[1], | 1499 | &reply[1], |
@@ -1585,26 +1585,26 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1585 | { | 1585 | { |
1586 | case AF_INET: | 1586 | case AF_INET: |
1587 | { | 1587 | { |
1588 | size_t size = sizeof (struct ip4_header) | 1588 | size_t size = sizeof (struct GNUNET_TUN_IPv4Header) |
1589 | + sizeof (struct tcp_packet) | 1589 | + sizeof (struct GNUNET_TUN_TcpHeader) |
1590 | + sizeof (struct GNUNET_MessageHeader) + | 1590 | + sizeof (struct GNUNET_MessageHeader) + |
1591 | sizeof (struct tun_header) + | 1591 | sizeof (struct GNUNET_TUN_Layer2PacketHeader) + |
1592 | mlen; | 1592 | mlen; |
1593 | { | 1593 | { |
1594 | char buf[size]; | 1594 | char buf[size]; |
1595 | struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf; | 1595 | struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf; |
1596 | struct tun_header *tun = (struct tun_header*) &msg[1]; | 1596 | struct GNUNET_TUN_Layer2PacketHeader *tun = (struct GNUNET_TUN_Layer2PacketHeader*) &msg[1]; |
1597 | struct ip4_header *ipv4 = (struct ip4_header *) &tun[1]; | 1597 | struct GNUNET_TUN_IPv4Header *ipv4 = (struct GNUNET_TUN_IPv4Header *) &tun[1]; |
1598 | struct tcp_packet *tcp = (struct tcp_packet *) &ipv4[1]; | 1598 | struct GNUNET_TUN_TcpHeader *tcp = (struct GNUNET_TUN_TcpHeader *) &ipv4[1]; |
1599 | msg->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); | 1599 | msg->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); |
1600 | msg->size = htons (size); | 1600 | msg->size = htons (size); |
1601 | tun->flags = htons (0); | 1601 | tun->flags = htons (0); |
1602 | tun->proto = htons (ETH_P_IPV4); | 1602 | tun->proto = htons (ETH_P_IPV4); |
1603 | ipv4->version = 4; | 1603 | ipv4->version = 4; |
1604 | ipv4->header_length = sizeof (struct ip4_header) / 4; | 1604 | ipv4->header_length = sizeof (struct GNUNET_TUN_IPv4Header) / 4; |
1605 | ipv4->diff_serv = 0; | 1605 | ipv4->diff_serv = 0; |
1606 | ipv4->total_length = htons (sizeof (struct ip4_header) + | 1606 | ipv4->total_length = htons (sizeof (struct GNUNET_TUN_IPv4Header) + |
1607 | sizeof (struct tcp_packet) + | 1607 | sizeof (struct GNUNET_TUN_TcpHeader) + |
1608 | mlen); | 1608 | mlen); |
1609 | ipv4->identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 1609 | ipv4->identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
1610 | UINT16_MAX + 1); | 1610 | UINT16_MAX + 1); |
@@ -1616,7 +1616,7 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1616 | ipv4->source_address = ts->destination_ip.v4; | 1616 | ipv4->source_address = ts->destination_ip.v4; |
1617 | ipv4->destination_address = ts->source_ip.v4; | 1617 | ipv4->destination_address = ts->source_ip.v4; |
1618 | ipv4->checksum = | 1618 | ipv4->checksum = |
1619 | GNUNET_CRYPTO_crc16_n (ipv4, sizeof (struct ip4_header)); | 1619 | GNUNET_CRYPTO_crc16_n (ipv4, sizeof (struct GNUNET_TUN_IPv4Header)); |
1620 | *tcp = data->tcp_header; | 1620 | *tcp = data->tcp_header; |
1621 | tcp->spt = htons (ts->destination_port); | 1621 | tcp->spt = htons (ts->destination_port); |
1622 | tcp->dpt = htons (ts->source_port); | 1622 | tcp->dpt = htons (ts->source_port); |
@@ -1631,9 +1631,9 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1631 | sum = GNUNET_CRYPTO_crc16_step (sum, | 1631 | sum = GNUNET_CRYPTO_crc16_step (sum, |
1632 | &ipv4->source_address, | 1632 | &ipv4->source_address, |
1633 | 2 * sizeof (struct in_addr)); | 1633 | 2 * sizeof (struct in_addr)); |
1634 | tmp = htonl ((IPPROTO_TCP << 16) | (mlen + sizeof (struct tcp_packet))); | 1634 | tmp = htonl ((IPPROTO_TCP << 16) | (mlen + sizeof (struct GNUNET_TUN_TcpHeader))); |
1635 | sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint32_t)); | 1635 | sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint32_t)); |
1636 | sum = GNUNET_CRYPTO_crc16_step (sum, tcp, mlen + sizeof (struct tcp_packet)); | 1636 | sum = GNUNET_CRYPTO_crc16_step (sum, tcp, mlen + sizeof (struct GNUNET_TUN_TcpHeader)); |
1637 | tcp->crc = GNUNET_CRYPTO_crc16_finish (sum); | 1637 | tcp->crc = GNUNET_CRYPTO_crc16_finish (sum); |
1638 | } | 1638 | } |
1639 | (void) GNUNET_HELPER_send (helper_handle, | 1639 | (void) GNUNET_HELPER_send (helper_handle, |
@@ -1645,17 +1645,17 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1645 | break; | 1645 | break; |
1646 | case AF_INET6: | 1646 | case AF_INET6: |
1647 | { | 1647 | { |
1648 | size_t size = sizeof (struct ip6_header) | 1648 | size_t size = sizeof (struct GNUNET_TUN_IPv6Header) |
1649 | + sizeof (struct tcp_packet) | 1649 | + sizeof (struct GNUNET_TUN_TcpHeader) |
1650 | + sizeof (struct GNUNET_MessageHeader) + | 1650 | + sizeof (struct GNUNET_MessageHeader) + |
1651 | sizeof (struct tun_header) + | 1651 | sizeof (struct GNUNET_TUN_Layer2PacketHeader) + |
1652 | mlen; | 1652 | mlen; |
1653 | { | 1653 | { |
1654 | char buf[size]; | 1654 | char buf[size]; |
1655 | struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf; | 1655 | struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) buf; |
1656 | struct tun_header *tun = (struct tun_header*) &msg[1]; | 1656 | struct GNUNET_TUN_Layer2PacketHeader *tun = (struct GNUNET_TUN_Layer2PacketHeader*) &msg[1]; |
1657 | struct ip6_header *ipv6 = (struct ip6_header *) &tun[1]; | 1657 | struct GNUNET_TUN_IPv6Header *ipv6 = (struct GNUNET_TUN_IPv6Header *) &tun[1]; |
1658 | struct tcp_packet *tcp = (struct tcp_packet *) &ipv6[1]; | 1658 | struct GNUNET_TUN_TcpHeader *tcp = (struct GNUNET_TUN_TcpHeader *) &ipv6[1]; |
1659 | msg->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); | 1659 | msg->type = htons (GNUNET_MESSAGE_TYPE_VPN_HELPER); |
1660 | msg->size = htons (size); | 1660 | msg->size = htons (size); |
1661 | tun->flags = htons (0); | 1661 | tun->flags = htons (0); |
@@ -1664,7 +1664,7 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1664 | ipv6->version = 6; | 1664 | ipv6->version = 6; |
1665 | ipv6->traffic_class_l = 0; | 1665 | ipv6->traffic_class_l = 0; |
1666 | ipv6->flow_label = 0; | 1666 | ipv6->flow_label = 0; |
1667 | ipv6->payload_length = htons (sizeof (struct tcp_packet) + sizeof (struct ip6_header) + mlen); | 1667 | ipv6->payload_length = htons (sizeof (struct GNUNET_TUN_TcpHeader) + sizeof (struct GNUNET_TUN_IPv6Header) + mlen); |
1668 | ipv6->next_header = IPPROTO_TCP; | 1668 | ipv6->next_header = IPPROTO_TCP; |
1669 | ipv6->hop_limit = 255; | 1669 | ipv6->hop_limit = 255; |
1670 | ipv6->source_address = ts->destination_ip.v6; | 1670 | ipv6->source_address = ts->destination_ip.v6; |
@@ -1677,12 +1677,12 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1677 | uint32_t tmp; | 1677 | uint32_t tmp; |
1678 | 1678 | ||
1679 | sum = GNUNET_CRYPTO_crc16_step (sum, &ipv6->source_address, 2 * sizeof (struct in6_addr)); | 1679 | sum = GNUNET_CRYPTO_crc16_step (sum, &ipv6->source_address, 2 * sizeof (struct in6_addr)); |
1680 | tmp = htonl (sizeof (struct tcp_packet) + mlen); | 1680 | tmp = htonl (sizeof (struct GNUNET_TUN_TcpHeader) + mlen); |
1681 | sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint32_t)); | 1681 | sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint32_t)); |
1682 | tmp = htonl (IPPROTO_TCP); | 1682 | tmp = htonl (IPPROTO_TCP); |
1683 | sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint32_t)); | 1683 | sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint32_t)); |
1684 | sum = GNUNET_CRYPTO_crc16_step (sum, tcp, | 1684 | sum = GNUNET_CRYPTO_crc16_step (sum, tcp, |
1685 | sizeof (struct tcp_packet) + mlen); | 1685 | sizeof (struct GNUNET_TUN_TcpHeader) + mlen); |
1686 | tcp->crc = GNUNET_CRYPTO_crc16_finish (sum); | 1686 | tcp->crc = GNUNET_CRYPTO_crc16_finish (sum); |
1687 | } | 1687 | } |
1688 | (void) GNUNET_HELPER_send (helper_handle, | 1688 | (void) GNUNET_HELPER_send (helper_handle, |