diff options
Diffstat (limited to 'src/gns/gnunet-dns2gns.c')
-rw-r--r-- | src/gns/gnunet-dns2gns.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c index 68d090579..d2eabf02c 100644 --- a/src/gns/gnunet-dns2gns.c +++ b/src/gns/gnunet-dns2gns.c | |||
@@ -92,6 +92,17 @@ struct Request | |||
92 | uint16_t original_request_id; | 92 | uint16_t original_request_id; |
93 | }; | 93 | }; |
94 | 94 | ||
95 | /** | ||
96 | * The address to bind to | ||
97 | */ | ||
98 | static in_addr_t address; | ||
99 | |||
100 | /** | ||
101 | * The IPv6 address to bind to | ||
102 | */ | ||
103 | static struct in6_addr address6; | ||
104 | |||
105 | |||
95 | 106 | ||
96 | /** | 107 | /** |
97 | * Handle to GNS resolver. | 108 | * Handle to GNS resolver. |
@@ -578,6 +589,7 @@ run (void *cls, | |||
578 | const char *cfgfile, | 589 | const char *cfgfile, |
579 | const struct GNUNET_CONFIGURATION_Handle *c) | 590 | const struct GNUNET_CONFIGURATION_Handle *c) |
580 | { | 591 | { |
592 | char *addr_str; | ||
581 | (void) cls; | 593 | (void) cls; |
582 | (void) args; | 594 | (void) args; |
583 | (void) cfgfile; | 595 | (void) cfgfile; |
@@ -602,6 +614,52 @@ run (void *cls, | |||
602 | gns = NULL; | 614 | gns = NULL; |
603 | return; | 615 | return; |
604 | } | 616 | } |
617 | |||
618 | /* Get address to bind to */ | ||
619 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (c, "dns2gns", | ||
620 | "BIND_TO", | ||
621 | &addr_str)) | ||
622 | { | ||
623 | //No address specified | ||
624 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
625 | "Don't know what to bind to...\n"); | ||
626 | GNUNET_free (addr_str); | ||
627 | GNUNET_SCHEDULER_shutdown (); | ||
628 | return; | ||
629 | } | ||
630 | if (1 != inet_pton (AF_INET, addr_str, &address)) | ||
631 | { | ||
632 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
633 | "Unable to parse address %s\n", | ||
634 | addr_str); | ||
635 | GNUNET_free (addr_str); | ||
636 | GNUNET_SCHEDULER_shutdown (); | ||
637 | return; | ||
638 | } | ||
639 | GNUNET_free (addr_str); | ||
640 | /* Get address to bind to */ | ||
641 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (c, "dns2gns", | ||
642 | "BIND_TO6", | ||
643 | &addr_str)) | ||
644 | { | ||
645 | //No address specified | ||
646 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
647 | "Don't know what to bind6 to...\n"); | ||
648 | GNUNET_free (addr_str); | ||
649 | GNUNET_SCHEDULER_shutdown (); | ||
650 | return; | ||
651 | } | ||
652 | if (1 != inet_pton (AF_INET6, addr_str, &address6)) | ||
653 | { | ||
654 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
655 | "Unable to parse IPv6 address %s\n", | ||
656 | addr_str); | ||
657 | GNUNET_free (addr_str); | ||
658 | GNUNET_SCHEDULER_shutdown (); | ||
659 | return; | ||
660 | } | ||
661 | GNUNET_free (addr_str); | ||
662 | |||
605 | listen_socket4 = GNUNET_NETWORK_socket_create (PF_INET, | 663 | listen_socket4 = GNUNET_NETWORK_socket_create (PF_INET, |
606 | SOCK_DGRAM, | 664 | SOCK_DGRAM, |
607 | IPPROTO_UDP); | 665 | IPPROTO_UDP); |
@@ -611,6 +669,7 @@ run (void *cls, | |||
611 | 669 | ||
612 | memset (&v4, 0, sizeof (v4)); | 670 | memset (&v4, 0, sizeof (v4)); |
613 | v4.sin_family = AF_INET; | 671 | v4.sin_family = AF_INET; |
672 | v4.sin_addr.s_addr = address; | ||
614 | #if HAVE_SOCKADDR_IN_SIN_LEN | 673 | #if HAVE_SOCKADDR_IN_SIN_LEN |
615 | v4.sin_len = sizeof (v4); | 674 | v4.sin_len = sizeof (v4); |
616 | #endif | 675 | #endif |
@@ -634,6 +693,7 @@ run (void *cls, | |||
634 | 693 | ||
635 | memset (&v6, 0, sizeof (v6)); | 694 | memset (&v6, 0, sizeof (v6)); |
636 | v6.sin6_family = AF_INET6; | 695 | v6.sin6_family = AF_INET6; |
696 | v6.sin6_addr = address6; | ||
637 | #if HAVE_SOCKADDR_IN_SIN_LEN | 697 | #if HAVE_SOCKADDR_IN_SIN_LEN |
638 | v6.sin6_len = sizeof (v6); | 698 | v6.sin6_len = sizeof (v6); |
639 | #endif | 699 | #endif |