aboutsummaryrefslogtreecommitdiff
path: root/src/tun
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-30 12:57:41 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-30 12:57:41 +0000
commite5c57ab0ffad11a6c1d05eb5be50574057d96699 (patch)
tree85d4aa9b18a620d357336647e3580efaa50010fe /src/tun
parentf60b84087bb5354b27e30665263fc5f2bec80eb1 (diff)
downloadgnunet-e5c57ab0ffad11a6c1d05eb5be50574057d96699.tar.gz
gnunet-e5c57ab0ffad11a6c1d05eb5be50574057d96699.zip
-simplify
Diffstat (limited to 'src/tun')
-rw-r--r--src/tun/tun.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/tun/tun.c b/src/tun/tun.c
index 9bec7d24a..1ce6605dc 100644
--- a/src/tun/tun.c
+++ b/src/tun/tun.c
@@ -50,17 +50,14 @@ GNUNET_TUN_initialize_ipv4_header (struct GNUNET_TUN_IPv4Header *ip,
50 const struct in_addr *dst) 50 const struct in_addr *dst)
51{ 51{
52 GNUNET_assert (payload_length <= UINT16_MAX - sizeof (struct GNUNET_TUN_IPv4Header)); 52 GNUNET_assert (payload_length <= UINT16_MAX - sizeof (struct GNUNET_TUN_IPv4Header));
53 memset (&ip, 0, sizeof (struct GNUNET_TUN_IPv4Header));
53 ip->header_length = sizeof (struct GNUNET_TUN_IPv4Header) / 4; 54 ip->header_length = sizeof (struct GNUNET_TUN_IPv4Header) / 4;
54 ip->version = 4; 55 ip->version = 4;
55 ip->diff_serv = 0;
56 ip->total_length = htons (sizeof (struct GNUNET_TUN_IPv4Header) + payload_length); 56 ip->total_length = htons (sizeof (struct GNUNET_TUN_IPv4Header) + payload_length);
57 ip->identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 57 ip->identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
58 65536); 58 65536);
59 ip->flags = 0;
60 ip->fragmentation_offset = 0;
61 ip->ttl = FRESH_TTL; 59 ip->ttl = FRESH_TTL;
62 ip->protocol = protocol; 60 ip->protocol = protocol;
63 ip->checksum = 0;
64 ip->source_address = *src; 61 ip->source_address = *src;
65 ip->destination_address = *dst; 62 ip->destination_address = *dst;
66 ip->checksum = GNUNET_CRYPTO_crc16_n (ip, sizeof (struct GNUNET_TUN_IPv4Header)); 63 ip->checksum = GNUNET_CRYPTO_crc16_n (ip, sizeof (struct GNUNET_TUN_IPv4Header));
@@ -84,10 +81,8 @@ GNUNET_TUN_initialize_ipv6_header (struct GNUNET_TUN_IPv6Header *ip,
84 const struct in6_addr *dst) 81 const struct in6_addr *dst)
85{ 82{
86 GNUNET_assert (payload_length <= UINT16_MAX - sizeof (struct GNUNET_TUN_IPv6Header)); 83 GNUNET_assert (payload_length <= UINT16_MAX - sizeof (struct GNUNET_TUN_IPv6Header));
84 memset (&ip, 0, sizeof (struct GNUNET_TUN_IPv6Header));
87 ip->version = 6; 85 ip->version = 6;
88 ip->traffic_class_h = 0;
89 ip->traffic_class_l = 0;
90 ip->flow_label = 0;
91 ip->next_header = protocol; 86 ip->next_header = protocol;
92 ip->payload_length = htons ((uint16_t) payload_length); 87 ip->payload_length = htons ((uint16_t) payload_length);
93 ip->hop_limit = FRESH_TTL; 88 ip->hop_limit = FRESH_TTL;