aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-17 19:22:23 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-17 19:22:23 +0000
commit40261ecc5bf242437f12cf91d035c138cf089a1e (patch)
treeb801c2939e97a1ed68e614e74a3ce47765dd82b5 /src/vpn
parent9d077316ac3c6a18a4b13e90d7549188c2fe1f81 (diff)
downloadgnunet-40261ecc5bf242437f12cf91d035c138cf089a1e.tar.gz
gnunet-40261ecc5bf242437f12cf91d035c138cf089a1e.zip
-move IPv4 header initialization to tun library
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/Makefile.am1
-rw-r--r--src/vpn/gnunet-service-vpn.c44
2 files changed, 11 insertions, 34 deletions
diff --git a/src/vpn/Makefile.am b/src/vpn/Makefile.am
index bb0993c66..786f94d6a 100644
--- a/src/vpn/Makefile.am
+++ b/src/vpn/Makefile.am
@@ -40,6 +40,7 @@ gnunet_service_vpn_SOURCES = \
40 gnunet-service-vpn.c 40 gnunet-service-vpn.c
41gnunet_service_vpn_LDADD = \ 41gnunet_service_vpn_LDADD = \
42 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 42 $(top_builddir)/src/statistics/libgnunetstatistics.la \
43 $(top_builddir)/src/tun/libgnunettun.la \
43 $(top_builddir)/src/util/libgnunetutil.la \ 44 $(top_builddir)/src/util/libgnunetutil.la \
44 $(top_builddir)/src/mesh/libgnunetmesh.la \ 45 $(top_builddir)/src/mesh/libgnunetmesh.la \
45 $(GN_LIBINTL) 46 $(GN_LIBINTL)
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);