diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-04 00:59:15 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-04 00:59:15 +0000 |
commit | 121d28141d051650c7ec60c83cbf917fce0516cd (patch) | |
tree | 41b017161be59aea4efcef7caeacb2db99c9b1dc /src/dns | |
parent | 0bc020d2fe8fa8aa1e6896cd38c7b9d6c2311267 (diff) | |
download | gnunet-121d28141d051650c7ec60c83cbf917fce0516cd.tar.gz gnunet-121d28141d051650c7ec60c83cbf917fce0516cd.zip |
-bugfixes and debugging
Diffstat (limited to 'src/dns')
-rw-r--r-- | src/dns/dns.conf | 3 | ||||
-rw-r--r-- | src/dns/gnunet-service-dns_new.c | 67 |
2 files changed, 53 insertions, 17 deletions
diff --git a/src/dns/dns.conf b/src/dns/dns.conf index f8590bf61..e5ec117cc 100644 --- a/src/dns/dns.conf +++ b/src/dns/dns.conf | |||
@@ -17,6 +17,7 @@ IPV6ADDR = 2001:DB8::1 | |||
17 | IPV6PREFIX = 126 | 17 | IPV6PREFIX = 126 |
18 | 18 | ||
19 | # Use RFC 3927-style link-local address | 19 | # Use RFC 3927-style link-local address |
20 | IPV4ADDR = 169.254.1.1 | 20 | IPV4ADDR = 10.5.0.1 |
21 | #IPV4ADDR = 169.254.1.1 | ||
21 | IPV4MASK = 255.255.0.0 | 22 | IPV4MASK = 255.255.0.0 |
22 | 23 | ||
diff --git a/src/dns/gnunet-service-dns_new.c b/src/dns/gnunet-service-dns_new.c index 8d9727425..16e3b7f53 100644 --- a/src/dns/gnunet-service-dns_new.c +++ b/src/dns/gnunet-service-dns_new.c | |||
@@ -419,9 +419,7 @@ request_done (struct RequestRecord *rr) | |||
419 | { | 419 | { |
420 | char buf[reply_len]; | 420 | char buf[reply_len]; |
421 | size_t off; | 421 | size_t off; |
422 | uint16_t *udp_crcp; | 422 | uint32_t udp_crc_sum; |
423 | char *udp_crc_start; | ||
424 | uint16_t udp_crc_length; | ||
425 | 423 | ||
426 | /* first, GNUnet message header */ | 424 | /* first, GNUnet message header */ |
427 | hdr = (struct GNUNET_MessageHeader*) buf; | 425 | hdr = (struct GNUNET_MessageHeader*) buf; |
@@ -443,8 +441,7 @@ request_done (struct RequestRecord *rr) | |||
443 | } | 441 | } |
444 | 442 | ||
445 | /* now IP header */ | 443 | /* now IP header */ |
446 | udp_crc_start = &buf[off]; | 444 | udp_crc_sum = 0; |
447 | udp_crc_length = reply_len - off; | ||
448 | switch (rr->src_addr.ss_family) | 445 | switch (rr->src_addr.ss_family) |
449 | { | 446 | { |
450 | case AF_INET: | 447 | case AF_INET: |
@@ -468,12 +465,31 @@ request_done (struct RequestRecord *rr) | |||
468 | ip.checksum = 0; /* checksum is optional */ | 465 | ip.checksum = 0; /* checksum is optional */ |
469 | ip.source_address = dst->sin_addr; | 466 | ip.source_address = dst->sin_addr; |
470 | ip.destination_address = src->sin_addr; | 467 | ip.destination_address = src->sin_addr; |
468 | |||
469 | inet_pton (AF_INET, "10.5.0.2", &ip.source_address); | ||
470 | //inet_pton (AF_INET, "10.5.0.1", &ip.destination_address); | ||
471 | 471 | ||
472 | ip.checksum = GNUNET_CRYPTO_crc16_n ((uint16_t*) &ip, sizeof (ip)); | 472 | ip.checksum = GNUNET_CRYPTO_crc16_n ((uint16_t*) &ip, sizeof (ip)); |
473 | |||
474 | udp_crc_sum = GNUNET_CRYPTO_crc16_step (udp_crc_sum, | ||
475 | (uint16_t *) &ip.source_address, | ||
476 | sizeof (struct in_addr) * 2); | ||
477 | { | ||
478 | uint16_t tmp; | ||
479 | |||
480 | tmp = htons (IPPROTO_UDP); | ||
481 | udp_crc_sum = GNUNET_CRYPTO_crc16_step (udp_crc_sum, | ||
482 | (uint16_t *) &tmp, | ||
483 | sizeof (uint16_t)); | ||
484 | tmp = htons (rr->payload_length + sizeof (struct udp_packet)); | ||
485 | udp_crc_sum = GNUNET_CRYPTO_crc16_step (udp_crc_sum, | ||
486 | (uint16_t *) &tmp, | ||
487 | sizeof (uint16_t)); | ||
488 | } | ||
473 | memcpy (&buf[off], &ip, sizeof (ip)); | 489 | memcpy (&buf[off], &ip, sizeof (ip)); |
474 | off += sizeof (ip); | 490 | off += sizeof (ip); |
475 | break; | ||
476 | } | 491 | } |
492 | break; | ||
477 | case AF_INET6: | 493 | case AF_INET6: |
478 | { | 494 | { |
479 | struct sockaddr_in6 *src = (struct sockaddr_in6 *) &rr->src_addr; | 495 | struct sockaddr_in6 *src = (struct sockaddr_in6 *) &rr->src_addr; |
@@ -491,6 +507,21 @@ request_done (struct RequestRecord *rr) | |||
491 | ip.hop_limit = 255; /* or lower? */ | 507 | ip.hop_limit = 255; /* or lower? */ |
492 | ip.source_address = dst->sin6_addr; | 508 | ip.source_address = dst->sin6_addr; |
493 | ip.destination_address = src->sin6_addr; | 509 | ip.destination_address = src->sin6_addr; |
510 | udp_crc_sum = GNUNET_CRYPTO_crc16_step (udp_crc_sum, | ||
511 | (uint16_t *) &ip.source_address, | ||
512 | sizeof (struct in6_addr) * 2); | ||
513 | { | ||
514 | uint32_t tmp; | ||
515 | |||
516 | tmp = htons (rr->payload_length + sizeof (struct udp_packet)); | ||
517 | udp_crc_sum = GNUNET_CRYPTO_crc16_step (udp_crc_sum, | ||
518 | (uint16_t *) &tmp, | ||
519 | sizeof (uint32_t)); | ||
520 | tmp = htons (IPPROTO_UDP); | ||
521 | udp_crc_sum = GNUNET_CRYPTO_crc16_step (udp_crc_sum, | ||
522 | (uint16_t *) &tmp, | ||
523 | sizeof (uint32_t)); | ||
524 | } | ||
494 | memcpy (&buf[off], &ip, sizeof (ip)); | 525 | memcpy (&buf[off], &ip, sizeof (ip)); |
495 | off += sizeof (ip); | 526 | off += sizeof (ip); |
496 | } | 527 | } |
@@ -506,13 +537,18 @@ request_done (struct RequestRecord *rr) | |||
506 | udp.spt = spt; | 537 | udp.spt = spt; |
507 | udp.dpt = dpt; | 538 | udp.dpt = dpt; |
508 | udp.len = htons (reply_len - off); | 539 | udp.len = htons (reply_len - off); |
509 | udp.crc = 0; /* checksum will be set later */ | 540 | udp.crc = 0; |
510 | 541 | udp_crc_sum = GNUNET_CRYPTO_crc16_step (udp_crc_sum, | |
542 | (uint16_t *) &udp, | ||
543 | sizeof (udp)); | ||
544 | udp_crc_sum = GNUNET_CRYPTO_crc16_step (udp_crc_sum, | ||
545 | (uint16_t *) rr->payload, | ||
546 | rr->payload_length); | ||
547 | udp.crc = GNUNET_CRYPTO_crc16_finish (udp_crc_sum); | ||
511 | memcpy (&buf[off], &udp, sizeof (udp)); | 548 | memcpy (&buf[off], &udp, sizeof (udp)); |
512 | udp_crcp = (uint16_t*) &buf[off + offsetof (struct udp_packet, crc)]; | ||
513 | off += sizeof (udp); | 549 | off += sizeof (udp); |
514 | } | 550 | } |
515 | /* now DNS header */ | 551 | /* now DNS payload */ |
516 | { | 552 | { |
517 | memcpy (&buf[off], rr->payload, rr->payload_length); | 553 | memcpy (&buf[off], rr->payload, rr->payload_length); |
518 | off += rr->payload_length; | 554 | off += rr->payload_length; |
@@ -521,8 +557,6 @@ request_done (struct RequestRecord *rr) | |||
521 | "Sending %u bytes UDP packet to TUN\n", | 557 | "Sending %u bytes UDP packet to TUN\n", |
522 | (unsigned int) rr->payload_length); | 558 | (unsigned int) rr->payload_length); |
523 | } | 559 | } |
524 | |||
525 | *udp_crcp = GNUNET_CRYPTO_crc16_n ((uint16_t *)udp_crc_start, udp_crc_length); | ||
526 | /* final checks & sending */ | 560 | /* final checks & sending */ |
527 | GNUNET_assert (off == reply_len); | 561 | GNUNET_assert (off == reply_len); |
528 | GNUNET_HELPER_send (hijacker, | 562 | GNUNET_HELPER_send (hijacker, |
@@ -634,6 +668,7 @@ next_phase (struct RequestRecord *rr) | |||
634 | case AF_INET: | 668 | case AF_INET: |
635 | dnsout = dnsout4; | 669 | dnsout = dnsout4; |
636 | salen = sizeof (struct ip4_header); | 670 | salen = sizeof (struct ip4_header); |
671 | inet_pton (AF_INET, "8.8.8.8", &((struct sockaddr_in*) &rr->dst_addr)->sin_addr); | ||
637 | break; | 672 | break; |
638 | case AF_INET6: | 673 | case AF_INET6: |
639 | dnsout = dnsout6; | 674 | dnsout = dnsout6; |
@@ -1222,7 +1257,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1222 | } | 1257 | } |
1223 | helper_argv[1] = ifc_name; | 1258 | helper_argv[1] = ifc_name; |
1224 | if ( (GNUNET_SYSERR == | 1259 | if ( (GNUNET_SYSERR == |
1225 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV6ADDR", | 1260 | GNUNET_CONFIGURATION_get_value_string (cfg, "dns", "IPV6ADDR", |
1226 | &ipv6addr)) ) | 1261 | &ipv6addr)) ) |
1227 | { | 1262 | { |
1228 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1263 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1232,7 +1267,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1232 | } | 1267 | } |
1233 | helper_argv[2] = ipv6addr; | 1268 | helper_argv[2] = ipv6addr; |
1234 | if (GNUNET_SYSERR == | 1269 | if (GNUNET_SYSERR == |
1235 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV6PREFIX", | 1270 | GNUNET_CONFIGURATION_get_value_string (cfg, "dns", "IPV6PREFIX", |
1236 | &ipv6prefix)) | 1271 | &ipv6prefix)) |
1237 | { | 1272 | { |
1238 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1273 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1243,7 +1278,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1243 | helper_argv[3] = ipv6prefix; | 1278 | helper_argv[3] = ipv6prefix; |
1244 | 1279 | ||
1245 | if (GNUNET_SYSERR == | 1280 | if (GNUNET_SYSERR == |
1246 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4ADDR", | 1281 | GNUNET_CONFIGURATION_get_value_string (cfg, "dns", "IPV4ADDR", |
1247 | &ipv4addr)) | 1282 | &ipv4addr)) |
1248 | { | 1283 | { |
1249 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1284 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1253,7 +1288,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1253 | } | 1288 | } |
1254 | helper_argv[4] = ipv4addr; | 1289 | helper_argv[4] = ipv4addr; |
1255 | if (GNUNET_SYSERR == | 1290 | if (GNUNET_SYSERR == |
1256 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4MASK", | 1291 | GNUNET_CONFIGURATION_get_value_string (cfg, "dns", "IPV4MASK", |
1257 | &ipv4mask)) | 1292 | &ipv4mask)) |
1258 | { | 1293 | { |
1259 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1294 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |