diff options
Diffstat (limited to 'src/dns/gnunet-service-dns.c')
-rw-r--r-- | src/dns/gnunet-service-dns.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/src/dns/gnunet-service-dns.c b/src/dns/gnunet-service-dns.c index 175215634..5dc6641e7 100644 --- a/src/dns/gnunet-service-dns.c +++ b/src/dns/gnunet-service-dns.c | |||
@@ -32,9 +32,6 @@ | |||
32 | #include "gnunet_statistics_service.h" | 32 | #include "gnunet_statistics_service.h" |
33 | #include "gnunet_tun_lib.h" | 33 | #include "gnunet_tun_lib.h" |
34 | 34 | ||
35 | #ifndef IPVERSION | ||
36 | #define IPVERSION 4 | ||
37 | #endif | ||
38 | 35 | ||
39 | /** | 36 | /** |
40 | * Phases each request goes through. | 37 | * Phases each request goes through. |
@@ -387,20 +384,13 @@ request_done (struct RequestRecord *rr) | |||
387 | 384 | ||
388 | spt = dst->sin_port; | 385 | spt = dst->sin_port; |
389 | dpt = src->sin_port; | 386 | dpt = src->sin_port; |
390 | ip.header_length = sizeof (struct GNUNET_TUN_IPv4Header) / 4; | 387 | GNUNET_TUN_initialize_ipv4_header (&ip, |
391 | ip.version = IPVERSION; /* aka 4 */ | 388 | IPPROTO_UDP, |
392 | ip.diff_serv = 0; | 389 | reply_len - off - sizeof (struct GNUNET_TUN_IPv4Header), |
393 | ip.total_length = htons ((uint16_t) reply_len - off); | 390 | &dst->sin_addr, |
394 | ip.identification = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 391 | &src->sin_addr); |
395 | 65536); | 392 | |
396 | ip.flags = 0; | 393 | |
397 | ip.fragmentation_offset = 0; | ||
398 | ip.ttl = 255; /* or lower? */ | ||
399 | ip.protocol = IPPROTO_UDP; | ||
400 | ip.checksum = 0; /* checksum is optional */ | ||
401 | ip.source_address = dst->sin_addr; | ||
402 | ip.destination_address = src->sin_addr; | ||
403 | ip.checksum = GNUNET_CRYPTO_crc16_n (&ip, sizeof (ip)); | ||
404 | 394 | ||
405 | udp_crc_sum = GNUNET_CRYPTO_crc16_step (udp_crc_sum, | 395 | udp_crc_sum = GNUNET_CRYPTO_crc16_step (udp_crc_sum, |
406 | &ip.source_address, | 396 | &ip.source_address, |
@@ -1062,7 +1052,7 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client, | |||
1062 | case ETH_P_IPV4: | 1052 | case ETH_P_IPV4: |
1063 | ip4 = (const struct GNUNET_TUN_IPv4Header *) &tun[1]; | 1053 | ip4 = (const struct GNUNET_TUN_IPv4Header *) &tun[1]; |
1064 | if ( (msize < sizeof (struct GNUNET_TUN_IPv4Header)) || | 1054 | if ( (msize < sizeof (struct GNUNET_TUN_IPv4Header)) || |
1065 | (ip4->version != IPVERSION) || | 1055 | (ip4->version != 4) || |
1066 | (ip4->header_length != sizeof (struct GNUNET_TUN_IPv4Header) / 4) || | 1056 | (ip4->header_length != sizeof (struct GNUNET_TUN_IPv4Header) / 4) || |
1067 | (ntohs(ip4->total_length) != msize) || | 1057 | (ntohs(ip4->total_length) != msize) || |
1068 | (ip4->protocol != IPPROTO_UDP) ) | 1058 | (ip4->protocol != IPPROTO_UDP) ) |
@@ -1119,7 +1109,7 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client, | |||
1119 | 1109 | ||
1120 | /* setup new request */ | 1110 | /* setup new request */ |
1121 | rr->phase = RP_INIT; | 1111 | rr->phase = RP_INIT; |
1122 | if (ip4->version == IPVERSION) | 1112 | if (ip4->version == 4) |
1123 | { | 1113 | { |
1124 | srca4 = (struct sockaddr_in*) &rr->src_addr; | 1114 | srca4 = (struct sockaddr_in*) &rr->src_addr; |
1125 | dsta4 = (struct sockaddr_in*) &rr->dst_addr; | 1115 | dsta4 = (struct sockaddr_in*) &rr->dst_addr; |