diff options
Diffstat (limited to 'src/vpn/gnunet-service-vpn.c')
-rw-r--r-- | src/vpn/gnunet-service-vpn.c | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c index 7aeabf457..f0cdf6a3c 100644 --- a/src/vpn/gnunet-service-vpn.c +++ b/src/vpn/gnunet-service-vpn.c | |||
@@ -1422,23 +1422,11 @@ receive_udp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
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 | GNUNET_TUN_initialize_ipv4_header (ipv4, |
1426 | ipv4->header_length = sizeof (struct GNUNET_TUN_IPv4Header) / 4; | 1426 | IPPROTO_UDP, |
1427 | ipv4->diff_serv = 0; | 1427 | sizeof (struct GNUNET_TUN_UdpHeader) + mlen, |
1428 | ipv4->total_length = htons (sizeof (struct GNUNET_TUN_IPv4Header) + | 1428 | &ts->destination_ip.v4, |
1429 | sizeof (struct GNUNET_TUN_UdpHeader) + | 1429 | &ts->source_ip.v4); |
1430 | mlen); | ||
1431 | ipv4->identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
1432 | UINT16_MAX + 1); | ||
1433 | ipv4->flags = 0; | ||
1434 | ipv4->fragmentation_offset = 0; | ||
1435 | ipv4->ttl = 255; | ||
1436 | ipv4->protocol = IPPROTO_UDP; | ||
1437 | ipv4->checksum = 0; | ||
1438 | ipv4->source_address = ts->destination_ip.v4; | ||
1439 | ipv4->destination_address = ts->source_ip.v4; | ||
1440 | ipv4->checksum = | ||
1441 | GNUNET_CRYPTO_crc16_n (ipv4, sizeof (struct GNUNET_TUN_IPv4Header)); | ||
1442 | if (0 == ntohs (reply->source_port)) | 1430 | if (0 == ntohs (reply->source_port)) |
1443 | udp->spt = htons (ts->destination_port); | 1431 | udp->spt = htons (ts->destination_port); |
1444 | else | 1432 | else |
@@ -1600,23 +1588,11 @@ receive_tcp_back (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel, | |||
1600 | msg->size = htons (size); | 1588 | msg->size = htons (size); |
1601 | tun->flags = htons (0); | 1589 | tun->flags = htons (0); |
1602 | tun->proto = htons (ETH_P_IPV4); | 1590 | tun->proto = htons (ETH_P_IPV4); |
1603 | ipv4->version = 4; | 1591 | GNUNET_TUN_initialize_ipv4_header (ipv4, |
1604 | ipv4->header_length = sizeof (struct GNUNET_TUN_IPv4Header) / 4; | 1592 | IPPROTO_TCP, |
1605 | ipv4->diff_serv = 0; | 1593 | sizeof (struct GNUNET_TUN_TcpHeader) + mlen, |
1606 | ipv4->total_length = htons (sizeof (struct GNUNET_TUN_IPv4Header) + | 1594 | &ts->destination_ip.v4, |
1607 | sizeof (struct GNUNET_TUN_TcpHeader) + | 1595 | &ts->source_ip.v4); |
1608 | mlen); | ||
1609 | ipv4->identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
1610 | UINT16_MAX + 1); | ||
1611 | ipv4->flags = 0; | ||
1612 | ipv4->fragmentation_offset = 0; | ||
1613 | ipv4->ttl = 255; | ||
1614 | ipv4->protocol = IPPROTO_TCP; | ||
1615 | ipv4->checksum = 0; | ||
1616 | ipv4->source_address = ts->destination_ip.v4; | ||
1617 | ipv4->destination_address = ts->source_ip.v4; | ||
1618 | ipv4->checksum = | ||
1619 | GNUNET_CRYPTO_crc16_n (ipv4, sizeof (struct GNUNET_TUN_IPv4Header)); | ||
1620 | *tcp = data->tcp_header; | 1596 | *tcp = data->tcp_header; |
1621 | tcp->spt = htons (ts->destination_port); | 1597 | tcp->spt = htons (ts->destination_port); |
1622 | tcp->dpt = htons (ts->source_port); | 1598 | tcp->dpt = htons (ts->source_port); |