diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-02 15:33:05 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-02 15:33:05 +0000 |
commit | b63b061c6fc20d9ad1db85911a83321d2a55a6e1 (patch) | |
tree | 3dfdd4908333e4e5c1439fb2bc812e4bfd734f0b /src/dns | |
parent | 2002c8dbf70f0809a6798fcaf3b8f9f23d181d35 (diff) | |
download | gnunet-b63b061c6fc20d9ad1db85911a83321d2a55a6e1.tar.gz gnunet-b63b061c6fc20d9ad1db85911a83321d2a55a6e1.zip |
-starting with new DNS service code
Diffstat (limited to 'src/dns')
-rw-r--r-- | src/dns/Makefile.am | 10 | ||||
-rw-r--r-- | src/dns/gnunet-service-dns_new.c | 33 |
2 files changed, 26 insertions, 17 deletions
diff --git a/src/dns/Makefile.am b/src/dns/Makefile.am index 393b70cd3..2d5efb2f6 100644 --- a/src/dns/Makefile.am +++ b/src/dns/Makefile.am | |||
@@ -32,7 +32,7 @@ lib_LTLIBRARIES = \ | |||
32 | libgnunetdns.la | 32 | libgnunetdns.la |
33 | 33 | ||
34 | bin_PROGRAMS = \ | 34 | bin_PROGRAMS = \ |
35 | gnunet-service-dns $(HIJACKBIN) | 35 | gnunet-service-dns gnunet-service-dns-new $(HIJACKBIN) |
36 | 36 | ||
37 | plugin_LTLIBRARIES = \ | 37 | plugin_LTLIBRARIES = \ |
38 | libgnunet_plugin_block_dns.la | 38 | libgnunet_plugin_block_dns.la |
@@ -55,6 +55,14 @@ gnunet_service_dns_LDADD = \ | |||
55 | $(top_builddir)/src/dns/libgnunetdnsparser.la \ | 55 | $(top_builddir)/src/dns/libgnunetdnsparser.la \ |
56 | $(GN_LIBINTL) | 56 | $(GN_LIBINTL) |
57 | 57 | ||
58 | gnunet_service_dns_new_SOURCES = \ | ||
59 | gnunet-service-dns_new.c | ||
60 | gnunet_service_dns_new_LDADD = \ | ||
61 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
62 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
63 | $(top_builddir)/src/dns/libgnunetdnsparser.la \ | ||
64 | $(GN_LIBINTL) | ||
65 | |||
58 | libgnunetdnsparser_la_SOURCES = \ | 66 | libgnunetdnsparser_la_SOURCES = \ |
59 | dnsparser.c | 67 | dnsparser.c |
60 | libgnunetdnsparser_la_LIBADD = \ | 68 | libgnunetdnsparser_la_LIBADD = \ |
diff --git a/src/dns/gnunet-service-dns_new.c b/src/dns/gnunet-service-dns_new.c index cfc7bc4c7..afaf13196 100644 --- a/src/dns/gnunet-service-dns_new.c +++ b/src/dns/gnunet-service-dns_new.c | |||
@@ -158,7 +158,7 @@ cleanup_task (void *cls GNUNET_UNUSED, | |||
158 | GNUNET_free_non_null (helper_argv[i]); | 158 | GNUNET_free_non_null (helper_argv[i]); |
159 | if (NULL != dnsout4) | 159 | if (NULL != dnsout4) |
160 | { | 160 | { |
161 | GNUNET_NETWORK_socket_destroy (dnsout4); | 161 | GNUNET_NETWORK_socket_close (dnsout4); |
162 | dnsout4 = NULL; | 162 | dnsout4 = NULL; |
163 | } | 163 | } |
164 | if (GNUNET_SCHEDULER_NO_TASK != read4_task) | 164 | if (GNUNET_SCHEDULER_NO_TASK != read4_task) |
@@ -168,7 +168,7 @@ cleanup_task (void *cls GNUNET_UNUSED, | |||
168 | } | 168 | } |
169 | if (NULL != dnsout6) | 169 | if (NULL != dnsout6) |
170 | { | 170 | { |
171 | GNUNET_NETWORK_socket_destroy (dnsout6); | 171 | GNUNET_NETWORK_socket_close (dnsout6); |
172 | dnsout6 = NULL; | 172 | dnsout6 = NULL; |
173 | } | 173 | } |
174 | if (GNUNET_SCHEDULER_NO_TASK != read6_task) | 174 | if (GNUNET_SCHEDULER_NO_TASK != read6_task) |
@@ -315,7 +315,7 @@ open_port4 () | |||
315 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 315 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
316 | _("Could not bind to any port: %s\n"), | 316 | _("Could not bind to any port: %s\n"), |
317 | STRERROR (errno)); | 317 | STRERROR (errno)); |
318 | GNUNET_NETWORK_socket_destroy (dnsout4); | 318 | GNUNET_NETWORK_socket_close (dnsout4); |
319 | dnsout4 = NULL; | 319 | dnsout4 = NULL; |
320 | return GNUNET_SYSERR; | 320 | return GNUNET_SYSERR; |
321 | } | 321 | } |
@@ -329,7 +329,7 @@ open_port4 () | |||
329 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 329 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
330 | _("Could not determine port I got: %s\n"), | 330 | _("Could not determine port I got: %s\n"), |
331 | STRERROR (errno)); | 331 | STRERROR (errno)); |
332 | GNUNET_NETWORK_socket_destroy (dnsout4); | 332 | GNUNET_NETWORK_socket_close (dnsout4); |
333 | dnsout4 = NULL; | 333 | dnsout4 = NULL; |
334 | return GNUNET_SYSERR; | 334 | return GNUNET_SYSERR; |
335 | } | 335 | } |
@@ -339,7 +339,7 @@ open_port4 () | |||
339 | _("GNUnet DNS will exit on source port %u\n"), | 339 | _("GNUnet DNS will exit on source port %u\n"), |
340 | (unsigned int) dnsoutport); | 340 | (unsigned int) dnsoutport); |
341 | read4_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 341 | read4_task = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
342 | dnsout, | 342 | dnsout4, |
343 | &read_response, dnsout4); | 343 | &read_response, dnsout4); |
344 | return GNUNET_OK; | 344 | return GNUNET_OK; |
345 | } | 345 | } |
@@ -355,6 +355,7 @@ static int | |||
355 | open_port6 () | 355 | open_port6 () |
356 | { | 356 | { |
357 | struct sockaddr_in6 addr; | 357 | struct sockaddr_in6 addr; |
358 | socklen_t addrlen; | ||
358 | 359 | ||
359 | dnsout6 = GNUNET_NETWORK_socket_create (AF_INET6, SOCK_DGRAM, 0); | 360 | dnsout6 = GNUNET_NETWORK_socket_create (AF_INET6, SOCK_DGRAM, 0); |
360 | if (dnsout6 == NULL) | 361 | if (dnsout6 == NULL) |
@@ -377,6 +378,8 @@ open_port6 () | |||
377 | _("Could not bind to port %u: %s\n"), | 378 | _("Could not bind to port %u: %s\n"), |
378 | (unsigned int) dnsoutport, | 379 | (unsigned int) dnsoutport, |
379 | STRERROR (errno)); | 380 | STRERROR (errno)); |
381 | GNUNET_NETWORK_socket_close (dnsout6); | ||
382 | dnsout6 = NULL; | ||
380 | return GNUNET_SYSERR; | 383 | return GNUNET_SYSERR; |
381 | } | 384 | } |
382 | if (0 == dnsoutport) | 385 | if (0 == dnsoutport) |
@@ -389,7 +392,7 @@ open_port6 () | |||
389 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 392 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
390 | _("Could not determine port I got: %s\n"), | 393 | _("Could not determine port I got: %s\n"), |
391 | STRERROR (errno)); | 394 | STRERROR (errno)); |
392 | GNUNET_NETWORK_socket_destroy (dnsout6); | 395 | GNUNET_NETWORK_socket_close (dnsout6); |
393 | dnsout6 = NULL; | 396 | dnsout6 = NULL; |
394 | return GNUNET_SYSERR; | 397 | return GNUNET_SYSERR; |
395 | } | 398 | } |
@@ -476,13 +479,11 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
476 | {NULL, NULL, 0, 0} | 479 | {NULL, NULL, 0, 0} |
477 | }; | 480 | }; |
478 | char port_s[6]; | 481 | char port_s[6]; |
479 | char *virt_dns; | ||
480 | struct GNUNET_OS_Process *proc; | ||
481 | char *ifc_name; | 482 | char *ifc_name; |
482 | char *ipv4_addr; | 483 | char *ipv4addr; |
483 | char *ipv4_mask; | 484 | char *ipv4mask; |
484 | char *ipv6_addr; | 485 | char *ipv6addr; |
485 | char *ipv6_mask; | 486 | char *ipv6prefix; |
486 | 487 | ||
487 | cfg = cfg_; | 488 | cfg = cfg_; |
488 | request_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 489 | request_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
@@ -521,7 +522,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
521 | GNUNET_SCHEDULER_shutdown (); | 522 | GNUNET_SCHEDULER_shutdown (); |
522 | return; | 523 | return; |
523 | } | 524 | } |
524 | helper_argv[2] = ipv6_addr; | 525 | helper_argv[2] = ipv6addr; |
525 | if (GNUNET_SYSERR == | 526 | if (GNUNET_SYSERR == |
526 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV6PREFIX", | 527 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV6PREFIX", |
527 | &ipv6prefix)) | 528 | &ipv6prefix)) |
@@ -531,7 +532,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
531 | GNUNET_SCHEDULER_shutdown (); | 532 | GNUNET_SCHEDULER_shutdown (); |
532 | return; | 533 | return; |
533 | } | 534 | } |
534 | helper_argv[3] = ipv6_mask; | 535 | helper_argv[3] = ipv6prefix; |
535 | 536 | ||
536 | if (GNUNET_SYSERR == | 537 | if (GNUNET_SYSERR == |
537 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4ADDR", | 538 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4ADDR", |
@@ -542,7 +543,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
542 | GNUNET_SCHEDULER_shutdown (); | 543 | GNUNET_SCHEDULER_shutdown (); |
543 | return; | 544 | return; |
544 | } | 545 | } |
545 | helper_argv[4] = ipv4_addr; | 546 | helper_argv[4] = ipv4addr; |
546 | if (GNUNET_SYSERR == | 547 | if (GNUNET_SYSERR == |
547 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4MASK", | 548 | GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4MASK", |
548 | &ipv4mask)) | 549 | &ipv4mask)) |
@@ -552,7 +553,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
552 | GNUNET_SCHEDULER_shutdown (); | 553 | GNUNET_SCHEDULER_shutdown (); |
553 | return; | 554 | return; |
554 | } | 555 | } |
555 | helper_argv[5] = ipv4_mask; | 556 | helper_argv[5] = ipv4mask; |
556 | GNUNET_snprintf (port_s, | 557 | GNUNET_snprintf (port_s, |
557 | sizeof (port_s), | 558 | sizeof (port_s), |
558 | "%u", | 559 | "%u", |