diff options
Diffstat (limited to 'src/tun/tun.c')
-rw-r--r-- | src/tun/tun.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/tun/tun.c b/src/tun/tun.c index 3b0e9b94a..ed3aef1c1 100644 --- a/src/tun/tun.c +++ b/src/tun/tun.c | |||
@@ -55,7 +55,7 @@ GNUNET_TUN_initialize_ipv4_header (struct GNUNET_TUN_IPv4Header *ip, | |||
55 | ip->header_length = sizeof (struct GNUNET_TUN_IPv4Header) / 4; | 55 | ip->header_length = sizeof (struct GNUNET_TUN_IPv4Header) / 4; |
56 | ip->version = 4; | 56 | ip->version = 4; |
57 | ip->total_length = htons (sizeof (struct GNUNET_TUN_IPv4Header) + payload_length); | 57 | ip->total_length = htons (sizeof (struct GNUNET_TUN_IPv4Header) + payload_length); |
58 | ip->identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 58 | ip->identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
59 | 65536); | 59 | 65536); |
60 | ip->ttl = FRESH_TTL; | 60 | ip->ttl = FRESH_TTL; |
61 | ip->protocol = protocol; | 61 | ip->protocol = protocol; |
@@ -89,7 +89,7 @@ GNUNET_TUN_initialize_ipv6_header (struct GNUNET_TUN_IPv6Header *ip, | |||
89 | ip->payload_length = htons ((uint16_t) payload_length); | 89 | ip->payload_length = htons ((uint16_t) payload_length); |
90 | ip->hop_limit = FRESH_TTL; | 90 | ip->hop_limit = FRESH_TTL; |
91 | ip->destination_address = *dst; | 91 | ip->destination_address = *dst; |
92 | ip->source_address = *src; | 92 | ip->source_address = *src; |
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
@@ -116,7 +116,7 @@ GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, | |||
116 | GNUNET_assert (IPPROTO_TCP == ip->protocol); | 116 | GNUNET_assert (IPPROTO_TCP == ip->protocol); |
117 | 117 | ||
118 | tcp->crc = 0; | 118 | tcp->crc = 0; |
119 | sum = GNUNET_CRYPTO_crc16_step (0, | 119 | sum = GNUNET_CRYPTO_crc16_step (0, |
120 | &ip->source_address, | 120 | &ip->source_address, |
121 | sizeof (struct in_addr) * 2); | 121 | sizeof (struct in_addr) * 2); |
122 | tmp = htons (IPPROTO_TCP); | 122 | tmp = htons (IPPROTO_TCP); |
@@ -186,21 +186,21 @@ GNUNET_TUN_calculate_udp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, | |||
186 | GNUNET_assert (IPPROTO_UDP == ip->protocol); | 186 | GNUNET_assert (IPPROTO_UDP == ip->protocol); |
187 | 187 | ||
188 | udp->crc = 0; /* technically optional, but we calculate it anyway, just to be sure */ | 188 | udp->crc = 0; /* technically optional, but we calculate it anyway, just to be sure */ |
189 | sum = GNUNET_CRYPTO_crc16_step (0, | 189 | sum = GNUNET_CRYPTO_crc16_step (0, |
190 | &ip->source_address, | 190 | &ip->source_address, |
191 | sizeof (struct in_addr) * 2); | 191 | sizeof (struct in_addr) * 2); |
192 | tmp = htons (IPPROTO_UDP); | 192 | tmp = htons (IPPROTO_UDP); |
193 | sum = GNUNET_CRYPTO_crc16_step (sum, | 193 | sum = GNUNET_CRYPTO_crc16_step (sum, |
194 | &tmp, | 194 | &tmp, |
195 | sizeof (uint16_t)); | 195 | sizeof (uint16_t)); |
196 | tmp = htons (sizeof (struct GNUNET_TUN_UdpHeader) + payload_length); | 196 | tmp = htons (sizeof (struct GNUNET_TUN_UdpHeader) + payload_length); |
197 | sum = GNUNET_CRYPTO_crc16_step (sum, | 197 | sum = GNUNET_CRYPTO_crc16_step (sum, |
198 | &tmp, | 198 | &tmp, |
199 | sizeof (uint16_t)); | 199 | sizeof (uint16_t)); |
200 | sum = GNUNET_CRYPTO_crc16_step (sum, | 200 | sum = GNUNET_CRYPTO_crc16_step (sum, |
201 | udp, | 201 | udp, |
202 | sizeof (struct GNUNET_TUN_UdpHeader)); | 202 | sizeof (struct GNUNET_TUN_UdpHeader)); |
203 | sum = GNUNET_CRYPTO_crc16_step (sum, | 203 | sum = GNUNET_CRYPTO_crc16_step (sum, |
204 | payload, | 204 | payload, |
205 | payload_length); | 205 | payload_length); |
206 | udp->crc = GNUNET_CRYPTO_crc16_finish (sum); | 206 | udp->crc = GNUNET_CRYPTO_crc16_finish (sum); |