aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-08-11 13:02:01 +0000
committerChristian Grothoff <christian@grothoff.org>2016-08-11 13:02:01 +0000
commit2a6e6e1654af25646b0f0812595ecf8e4319f643 (patch)
tree4ab2e8ba0283c540a1759f3ed3da346efd40ba54
parent666c8fa4c8e4ff13487dca37f26c26663adff579 (diff)
downloadgnunet-2a6e6e1654af25646b0f0812595ecf8e4319f643.tar.gz
gnunet-2a6e6e1654af25646b0f0812595ecf8e4319f643.zip
-convert vpn/exit/pt to use new CADET ports
-rw-r--r--src/exit/gnunet-daemon-exit.c419
-rw-r--r--src/include/gnunet_applications.h46
-rw-r--r--src/include/gnunet_common.h1
-rw-r--r--src/pt/gnunet-daemon-pt.c139
-rw-r--r--src/testbed/gnunet-service-testbed_barriers.c3
-rw-r--r--src/util/crypto_kdf.c39
-rw-r--r--src/vpn/gnunet-service-vpn.c83
-rw-r--r--src/vpn/vpn_api.c4
8 files changed, 442 insertions, 292 deletions
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index 2b9ddc722..c8a2e85ef 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -3480,81 +3480,30 @@ do_dht_put (void *cls)
3480 sizeof (struct GNUNET_DNS_Advertisement), 3480 sizeof (struct GNUNET_DNS_Advertisement),
3481 &dns_advertisement, 3481 &dns_advertisement,
3482 expiration, 3482 expiration,
3483 &dht_put_cont, NULL); 3483 &dht_put_cont,
3484 NULL);
3484} 3485}
3485 3486
3486 3487
3487/** 3488/**
3488 * @brief Main function that will be run by the scheduler. 3489 * Figure out which IP versions we should support (and which
3489 * 3490 * are supported by the OS) according to our configuration.
3490 * @param cls closure
3491 * @param args remaining command-line arguments
3492 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
3493 * @param cfg_ configuration
3494 */ 3491 */
3495static void 3492static void
3496run (void *cls, 3493parse_ip_options ()
3497 char *const *args,
3498 const char *cfgfile,
3499 const struct GNUNET_CONFIGURATION_Handle *cfg_)
3500{ 3494{
3501 static struct GNUNET_CADET_MessageHandler handlers[] = { 3495 ipv4_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg,
3502 {&receive_icmp_service, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE, 0}, 3496 "exit",
3503 {&receive_icmp_remote, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_INTERNET, 0}, 3497 "EXIT_IPV4");
3504 {&receive_udp_service, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE, 0}, 3498 ipv6_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg,
3505 {&receive_udp_remote, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET, 0}, 3499 "exit",
3506 {&receive_tcp_service, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START, 0}, 3500 "EXIT_IPV6");
3507 {&receive_tcp_remote, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START, 0}, 3501 ipv4_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg,
3508 {&receive_tcp_data, GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_EXIT, 0}, 3502 "exit",
3509 {&receive_dns_request, GNUNET_MESSAGE_TYPE_VPN_DNS_TO_INTERNET, 0}, 3503 "ENABLE_IPV4");
3510 {NULL, 0, 0} 3504 ipv6_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg,
3511 }; 3505 "exit",
3512 3506 "ENABLE_IPV6");
3513 static uint32_t apptypes[] = {
3514 GNUNET_APPLICATION_TYPE_END,
3515 GNUNET_APPLICATION_TYPE_END,
3516 GNUNET_APPLICATION_TYPE_END,
3517 GNUNET_APPLICATION_TYPE_END
3518 };
3519 unsigned int app_idx;
3520 char *exit_ifname;
3521 char *tun_ifname;
3522 char *policy;
3523 char *ipv6addr;
3524 char *ipv6prefix_s;
3525 char *ipv4addr;
3526 char *ipv4mask;
3527 char *binary;
3528 char *regex;
3529 char *prefixed_regex;
3530 struct in_addr dns_exit4;
3531 struct in6_addr dns_exit6;
3532 char *dns_exit;
3533
3534 cfg = cfg_;
3535 ipv4_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "EXIT_IPV4");
3536 ipv6_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "EXIT_IPV6");
3537 ipv4_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV4");
3538 ipv6_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV6");
3539 if ( (ipv4_exit) || (ipv6_exit) )
3540 {
3541 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit");
3542 if (GNUNET_YES !=
3543 GNUNET_OS_check_helper_binary (binary, GNUNET_YES, "-d gnunet-vpn - - - 169.1.3.3.7 255.255.255.0")) //no nat, ipv4 only
3544 {
3545 GNUNET_free (binary);
3546 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3547 _("`%s' must be installed SUID, EXIT will not work\n"),
3548 "gnunet-helper-exit");
3549 GNUNET_SCHEDULER_add_shutdown (&dummy_task,
3550 NULL);
3551 global_ret = 1;
3552 return;
3553 }
3554 GNUNET_free (binary);
3555 }
3556 stats = GNUNET_STATISTICS_create ("exit", cfg);
3557
3558 if ( (ipv4_exit || ipv4_enabled) && 3507 if ( (ipv4_exit || ipv4_enabled) &&
3559 GNUNET_OK != GNUNET_NETWORK_test_pf (PF_INET)) 3508 GNUNET_OK != GNUNET_NETWORK_test_pf (PF_INET))
3560 { 3509 {
@@ -3583,83 +3532,110 @@ run (void *cls,
3583 _("Cannot enable IPv6 exit but disable IPv6 on TUN interface, will use ENABLE_IPv6=YES\n")); 3532 _("Cannot enable IPv6 exit but disable IPv6 on TUN interface, will use ENABLE_IPv6=YES\n"));
3584 ipv6_enabled = GNUNET_YES; 3533 ipv6_enabled = GNUNET_YES;
3585 } 3534 }
3586 if (! (ipv4_enabled || ipv6_enabled)) 3535}
3587 { 3536
3588 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3537
3589 _("No useful service enabled. Exiting.\n")); 3538/**
3590 GNUNET_SCHEDULER_shutdown (); 3539 * Helper function to open the CADET port for DNS exits and to
3591 return; 3540 * advertise the DNS exit (if applicable).
3592 } 3541 */
3542static void
3543advertise_dns_exit ()
3544{
3545 char *dns_exit;
3546 struct GNUNET_HashCode port;
3547 struct in_addr dns_exit4;
3548 struct in6_addr dns_exit6;
3593 3549
3594 dns_exit = NULL; 3550 if (GNUNET_YES !=
3595 if ( (GNUNET_YES == 3551 GNUNET_CONFIGURATION_get_value_yesno (cfg,
3596 GNUNET_CONFIGURATION_get_value_yesno (cfg_, "exit", "EXIT_DNS")) && 3552 "exit",
3597 ( (GNUNET_OK != 3553 "EXIT_DNS"))
3598 GNUNET_CONFIGURATION_get_value_string (cfg, "exit", 3554 return;
3599 "DNS_RESOLVER", 3555 if ( (GNUNET_OK !=
3600 &dns_exit)) || 3556 GNUNET_CONFIGURATION_get_value_string (cfg,
3601 ( (1 != inet_pton (AF_INET, dns_exit, &dns_exit4)) && 3557 "exit",
3602 (1 != inet_pton (AF_INET6, dns_exit, &dns_exit6)) ) ) ) 3558 "DNS_RESOLVER",
3559 &dns_exit)) ||
3560 ( (1 != inet_pton (AF_INET,
3561 dns_exit,
3562 &dns_exit4)) &&
3563 (1 != inet_pton (AF_INET6,
3564 dns_exit,
3565 &dns_exit6)) ) )
3603 { 3566 {
3604 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, 3567 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
3605 "dns", "DNS_RESOLVER", 3568 "dns",
3569 "DNS_RESOLVER",
3606 _("need a valid IPv4 or IPv6 address\n")); 3570 _("need a valid IPv4 or IPv6 address\n"));
3607 GNUNET_free_non_null (dns_exit); 3571 return;
3608 dns_exit = NULL; 3572 }
3609 } 3573 /* open port */
3610 app_idx = 0; 3574 GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_INTERNET_RESOLVER,
3611 if (GNUNET_YES == ipv4_exit) 3575 strlen (GNUNET_APPLICATION_PORT_INTERNET_RESOLVER),
3612 { 3576 &port);
3613 apptypes[app_idx] = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY; 3577 GNUNET_CADET_open_port (cadet_handle,
3614 app_idx++; 3578 &port,
3615 } 3579 &new_channel,
3616 if (GNUNET_YES == ipv6_exit) 3580 NULL);
3617 { 3581 /* advertise exit */
3618 apptypes[app_idx] = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY; 3582 dht = GNUNET_DHT_connect (cfg,
3619 app_idx++; 3583 1);
3620 } 3584 peer_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg);
3621 if (NULL != dns_exit) 3585 GNUNET_CRYPTO_eddsa_key_get_public (peer_key,
3622 { 3586 &dns_advertisement.peer.public_key);
3623 dht = GNUNET_DHT_connect (cfg, 1); 3587 dns_advertisement.purpose.size = htonl (sizeof (struct GNUNET_DNS_Advertisement) -
3624 peer_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg); 3588 sizeof (struct GNUNET_CRYPTO_EddsaSignature));
3625 GNUNET_CRYPTO_eddsa_key_get_public (peer_key, 3589 dns_advertisement.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DNS_RECORD);
3626 &dns_advertisement.peer.public_key); 3590 GNUNET_CRYPTO_hash ("dns",
3627 dns_advertisement.purpose.size = htonl (sizeof (struct GNUNET_DNS_Advertisement) - 3591 strlen ("dns"),
3628 sizeof (struct GNUNET_CRYPTO_EddsaSignature)); 3592 &dht_put_key);
3629 dns_advertisement.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DNS_RECORD); 3593 dht_task = GNUNET_SCHEDULER_add_now (&do_dht_put,
3630 GNUNET_CRYPTO_hash ("dns", 3594 NULL);
3631 strlen ("dns"), 3595 GNUNET_free (dns_exit);
3632 &dht_put_key); 3596}
3633 dht_task = GNUNET_SCHEDULER_add_now (&do_dht_put, 3597
3634 NULL); 3598
3635 apptypes[app_idx] = GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER; 3599/**
3636 app_idx++; 3600 * Initialize #exit_argv.
3637 } 3601 *
3638 GNUNET_free_non_null (dns_exit); 3602 * @return #GNUNET_OK on success, #GNUNET_SYSERR if we should shutdown
3639 GNUNET_SCHEDULER_add_shutdown (&cleanup, 3603 */
3640 NULL); 3604static int
3605setup_exit_helper_args ()
3606{
3607 char *exit_ifname;
3608 char *tun_ifname;
3609 char *ipv6addr;
3610 char *ipv6prefix_s;
3611 char *ipv4addr;
3612 char *ipv4mask;
3641 3613
3642 if (GNUNET_OK !=
3643 GNUNET_CONFIGURATION_get_value_number (cfg, "exit", "MAX_CONNECTIONS",
3644 &max_connections))
3645 max_connections = 1024;
3646 exit_argv[0] = GNUNET_strdup ("exit-gnunet"); 3614 exit_argv[0] = GNUNET_strdup ("exit-gnunet");
3647 if (GNUNET_SYSERR == 3615 if (GNUNET_SYSERR ==
3648 GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "TUN_IFNAME", &tun_ifname)) 3616 GNUNET_CONFIGURATION_get_value_string (cfg,
3617 "exit",
3618 "TUN_IFNAME",
3619 &tun_ifname))
3649 { 3620 {
3650 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "TUN_IFNAME"); 3621 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
3651 GNUNET_SCHEDULER_shutdown (); 3622 "EXIT",
3652 return; 3623 "TUN_IFNAME");
3624 return GNUNET_SYSERR;
3653 } 3625 }
3654 exit_argv[1] = tun_ifname; 3626 exit_argv[1] = tun_ifname;
3655 if (ipv4_enabled) 3627 if (ipv4_enabled)
3656 { 3628 {
3657 if (GNUNET_SYSERR == 3629 if (GNUNET_SYSERR ==
3658 GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "EXIT_IFNAME", &exit_ifname)) 3630 GNUNET_CONFIGURATION_get_value_string (cfg,
3631 "exit",
3632 "EXIT_IFNAME",
3633 &exit_ifname))
3659 { 3634 {
3660 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "EXIT_IFNAME"); 3635 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
3661 GNUNET_SCHEDULER_shutdown (); 3636 "EXIT",
3662 return; 3637 "EXIT_IFNAME");
3638 return GNUNET_SYSERR;
3663 } 3639 }
3664 exit_argv[2] = exit_ifname; 3640 exit_argv[2] = exit_ifname;
3665 } 3641 }
@@ -3668,7 +3644,6 @@ run (void *cls,
3668 exit_argv[2] = GNUNET_strdup ("-"); 3644 exit_argv[2] = GNUNET_strdup ("-");
3669 } 3645 }
3670 3646
3671
3672 if (GNUNET_YES == ipv6_enabled) 3647 if (GNUNET_YES == ipv6_enabled)
3673 { 3648 {
3674 ipv6addr = NULL; 3649 ipv6addr = NULL;
@@ -3677,33 +3652,41 @@ run (void *cls,
3677 "exit", 3652 "exit",
3678 "IPV6ADDR", 3653 "IPV6ADDR",
3679 &ipv6addr) || 3654 &ipv6addr) ||
3680 (1 != inet_pton (AF_INET6, ipv6addr, &exit_ipv6addr))) ) 3655 (1 != inet_pton (AF_INET6,
3656 ipv6addr,
3657 &exit_ipv6addr))) )
3681 { 3658 {
3682 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV6ADDR"); 3659 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
3683 GNUNET_SCHEDULER_shutdown (); 3660 "EXIT",
3661 "IPV6ADDR");
3684 GNUNET_free_non_null (ipv6addr); 3662 GNUNET_free_non_null (ipv6addr);
3685 return; 3663 return GNUNET_SYSERR;
3686 } 3664 }
3687 exit_argv[3] = ipv6addr; 3665 exit_argv[3] = ipv6addr;
3688 if (GNUNET_SYSERR == 3666 if (GNUNET_SYSERR ==
3689 GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV6PREFIX", 3667 GNUNET_CONFIGURATION_get_value_string (cfg,
3668 "exit",
3669 "IPV6PREFIX",
3690 &ipv6prefix_s)) 3670 &ipv6prefix_s))
3691 { 3671 {
3692 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV6PREFIX"); 3672 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
3693 GNUNET_SCHEDULER_shutdown (); 3673 "EXIT",
3694 return; 3674 "IPV6PREFIX");
3675 return GNUNET_SYSERR;
3695 } 3676 }
3696 exit_argv[4] = ipv6prefix_s; 3677 exit_argv[4] = ipv6prefix_s;
3697 if ( (GNUNET_OK != 3678 if ( (GNUNET_OK !=
3698 GNUNET_CONFIGURATION_get_value_number (cfg, "exit", 3679 GNUNET_CONFIGURATION_get_value_number (cfg,
3680 "exit",
3699 "IPV6PREFIX", 3681 "IPV6PREFIX",
3700 &ipv6prefix)) || 3682 &ipv6prefix)) ||
3701 (ipv6prefix >= 127) ) 3683 (ipv6prefix >= 127) )
3702 { 3684 {
3703 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV6PREFIX", 3685 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
3686 "EXIT",
3687 "IPV6PREFIX",
3704 _("Must be a number")); 3688 _("Must be a number"));
3705 GNUNET_SCHEDULER_shutdown (); 3689 return GNUNET_SYSERR;
3706 return;
3707 } 3690 }
3708 } 3691 }
3709 else 3692 else
@@ -3716,26 +3699,36 @@ run (void *cls,
3716 { 3699 {
3717 ipv4addr = NULL; 3700 ipv4addr = NULL;
3718 if ( (GNUNET_SYSERR == 3701 if ( (GNUNET_SYSERR ==
3719 GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4ADDR", 3702 GNUNET_CONFIGURATION_get_value_string (cfg,
3703 "exit",
3704 "IPV4ADDR",
3720 &ipv4addr) || 3705 &ipv4addr) ||
3721 (1 != inet_pton (AF_INET, ipv4addr, &exit_ipv4addr))) ) 3706 (1 != inet_pton (AF_INET,
3707 ipv4addr,
3708 &exit_ipv4addr))) )
3722 { 3709 {
3723 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV4ADDR"); 3710 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
3724 GNUNET_SCHEDULER_shutdown (); 3711 "EXIT",
3712 "IPV4ADDR");
3725 GNUNET_free_non_null (ipv4addr); 3713 GNUNET_free_non_null (ipv4addr);
3726 return; 3714 return GNUNET_SYSERR;
3727 } 3715 }
3728 exit_argv[5] = ipv4addr; 3716 exit_argv[5] = ipv4addr;
3729 ipv4mask = NULL; 3717 ipv4mask = NULL;
3730 if ( (GNUNET_SYSERR == 3718 if ( (GNUNET_SYSERR ==
3731 GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4MASK", 3719 GNUNET_CONFIGURATION_get_value_string (cfg,
3720 "exit",
3721 "IPV4MASK",
3732 &ipv4mask) || 3722 &ipv4mask) ||
3733 (1 != inet_pton (AF_INET, ipv4mask, &exit_ipv4mask))) ) 3723 (1 != inet_pton (AF_INET,
3724 ipv4mask,
3725 &exit_ipv4mask))) )
3734 { 3726 {
3735 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV4MASK"); 3727 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
3736 GNUNET_SCHEDULER_shutdown (); 3728 "EXIT",
3729 "IPV4MASK");
3737 GNUNET_free_non_null (ipv4mask); 3730 GNUNET_free_non_null (ipv4mask);
3738 return; 3731 return GNUNET_SYSERR;
3739 } 3732 }
3740 exit_argv[6] = ipv4mask; 3733 exit_argv[6] = ipv4mask;
3741 } 3734 }
@@ -3746,38 +3739,119 @@ run (void *cls,
3746 exit_argv[6] = GNUNET_strdup ("-"); 3739 exit_argv[6] = GNUNET_strdup ("-");
3747 } 3740 }
3748 exit_argv[7] = NULL; 3741 exit_argv[7] = NULL;
3742 return GNUNET_OK;
3743}
3749 3744
3750 udp_services = GNUNET_CONTAINER_multihashmap_create (65536, GNUNET_NO);
3751 tcp_services = GNUNET_CONTAINER_multihashmap_create (65536, GNUNET_NO);
3752 GNUNET_CONFIGURATION_iterate_sections (cfg, &read_service_conf, NULL);
3753 3745
3754 connections_map = GNUNET_CONTAINER_multihashmap_create (65536, GNUNET_NO); 3746/**
3755 connections_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 3747 * @brief Main function that will be run by the scheduler.
3756 if (0 == app_idx) 3748 *
3749 * @param cls closure
3750 * @param args remaining command-line arguments
3751 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
3752 * @param cfg_ configuration
3753 */
3754static void
3755run (void *cls,
3756 char *const *args,
3757 const char *cfgfile,
3758 const struct GNUNET_CONFIGURATION_Handle *cfg_)
3759{
3760 static struct GNUNET_CADET_MessageHandler handlers[] = {
3761 {&receive_icmp_service, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE, 0},
3762 {&receive_icmp_remote, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_INTERNET, 0},
3763 {&receive_udp_service, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE, 0},
3764 {&receive_udp_remote, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET, 0},
3765 {&receive_tcp_service, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START, 0},
3766 {&receive_tcp_remote, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START, 0},
3767 {&receive_tcp_data, GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_EXIT, 0},
3768 {&receive_dns_request, GNUNET_MESSAGE_TYPE_VPN_DNS_TO_INTERNET, 0},
3769 {NULL, 0, 0}
3770 };
3771 struct GNUNET_HashCode port;
3772 char *policy;
3773 char *binary;
3774 char *regex;
3775 char *prefixed_regex;
3776
3777 cfg = cfg_;
3778 if (GNUNET_OK !=
3779 GNUNET_CONFIGURATION_get_value_number (cfg,
3780 "exit",
3781 "MAX_CONNECTIONS",
3782 &max_connections))
3783 max_connections = 1024;
3784 parse_ip_options ();
3785 if ( (ipv4_exit) || (ipv6_exit) )
3786 {
3787 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit");
3788 if (GNUNET_YES !=
3789 GNUNET_OS_check_helper_binary (binary,
3790 GNUNET_YES,
3791 "-d gnunet-vpn - - - 169.1.3.3.7 255.255.255.0")) //no nat, ipv4 only
3792 {
3793 GNUNET_free (binary);
3794 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3795 _("`%s' must be installed SUID, EXIT will not work\n"),
3796 "gnunet-helper-exit");
3797 GNUNET_SCHEDULER_add_shutdown (&dummy_task,
3798 NULL);
3799 global_ret = 1;
3800 return;
3801 }
3802 GNUNET_free (binary);
3803 }
3804 if (! (ipv4_enabled || ipv6_enabled))
3757 { 3805 {
3758 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3806 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3759 _("No useful service enabled. Exiting.\n")); 3807 _("No useful service enabled. Exiting.\n"));
3760 GNUNET_SCHEDULER_shutdown (); 3808 GNUNET_SCHEDULER_shutdown ();
3761 return; 3809 return;
3762 } 3810 }
3763 cadet_handle = GNUNET_CADET_connect (cfg, NULL, &clean_channel, handlers); 3811
3812 GNUNET_SCHEDULER_add_shutdown (&cleanup,
3813 NULL);
3814 stats = GNUNET_STATISTICS_create ("exit",
3815 cfg);
3816 cadet_handle = GNUNET_CADET_connect (cfg,
3817 NULL,
3818 &clean_channel,
3819 handlers);
3764 if (NULL == cadet_handle) 3820 if (NULL == cadet_handle)
3765 { 3821 {
3766 GNUNET_SCHEDULER_shutdown (); 3822 GNUNET_SCHEDULER_shutdown ();
3767 return; 3823 return;
3768 } 3824 }
3769 for (int i = 0; 3825 advertise_dns_exit ();
3770 GNUNET_APPLICATION_TYPE_END != apptypes[i] 3826 if (GNUNET_OK !=
3771 && i < sizeof (apptypes)/sizeof (*apptypes); 3827 setup_exit_helper_args ())
3772 i++)
3773 { 3828 {
3774 GNUNET_CADET_open_port (cadet_handle, GC_u2h (apptypes[i]), 3829 GNUNET_SCHEDULER_shutdown ();
3775 &new_channel, NULL); 3830 return;
3776 } 3831 }
3777 3832
3778 /* Cadet handle acquired, now announce regular expressions matching our exit */ 3833 udp_services = GNUNET_CONTAINER_multihashmap_create (65536,
3834 GNUNET_NO);
3835 tcp_services = GNUNET_CONTAINER_multihashmap_create (65536,
3836 GNUNET_NO);
3837 connections_map = GNUNET_CONTAINER_multihashmap_create (65536,
3838 GNUNET_NO);
3839 connections_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
3840 GNUNET_CONFIGURATION_iterate_sections (cfg,
3841 &read_service_conf,
3842 NULL);
3843
3844 /* Cadet handle acquired, now open ports and announce regular
3845 expressions matching our exit */
3779 if ( (GNUNET_YES == ipv4_enabled) && (GNUNET_YES == ipv4_exit) ) 3846 if ( (GNUNET_YES == ipv4_enabled) && (GNUNET_YES == ipv4_exit) )
3780 { 3847 {
3848 GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_IPV4_GATEWAY,
3849 strlen (GNUNET_APPLICATION_PORT_IPV4_GATEWAY),
3850 &port);
3851 GNUNET_CADET_open_port (cadet_handle,
3852 &port,
3853 &new_channel,
3854 NULL);
3781 policy = NULL; 3855 policy = NULL;
3782 if (GNUNET_OK != 3856 if (GNUNET_OK !=
3783 GNUNET_CONFIGURATION_get_value_string (cfg, 3857 GNUNET_CONFIGURATION_get_value_string (cfg,
@@ -3803,8 +3877,15 @@ run (void *cls,
3803 } 3877 }
3804 } 3878 }
3805 3879
3806 if (GNUNET_YES == ipv6_enabled && GNUNET_YES == ipv6_exit) 3880 if ( (GNUNET_YES == ipv6_enabled) && (GNUNET_YES == ipv6_exit) )
3807 { 3881 {
3882 GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_IPV6_GATEWAY,
3883 strlen (GNUNET_APPLICATION_PORT_IPV6_GATEWAY),
3884 &port);
3885 GNUNET_CADET_open_port (cadet_handle,
3886 &port,
3887 &new_channel,
3888 NULL);
3808 policy = NULL; 3889 policy = NULL;
3809 if (GNUNET_OK != 3890 if (GNUNET_OK !=
3810 GNUNET_CONFIGURATION_get_value_string (cfg, 3891 GNUNET_CONFIGURATION_get_value_string (cfg,
diff --git a/src/include/gnunet_applications.h b/src/include/gnunet_applications.h
index 6d05cee17..1817fcac7 100644
--- a/src/include/gnunet_applications.h
+++ b/src/include/gnunet_applications.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2011 GNUnet e.V. 3 Copyright (C) 2011, 2016 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -51,80 +51,70 @@ extern "C"
51#define GNUNET_APPLICATION_TYPE_TEST 1 51#define GNUNET_APPLICATION_TYPE_TEST 1
52 52
53/** 53/**
54 * Internet DNS resolution (external DNS gateway). 54 * Transfer of blocks for non-anonymmous file-sharing.
55 */ 55 */
56#define GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER 2 56#define GNUNET_APPLICATION_TYPE_FS_BLOCK_TRANSFER 3
57 57
58/** 58/**
59 * Transfer of blocks for non-anonymmous file-sharing. 59 * Internet DNS resolution (external DNS gateway). This is a "well-known"
60 * service a peer may offer over CADET where the port is the hash of this
61 * string.
60 */ 62 */
61#define GNUNET_APPLICATION_TYPE_FS_BLOCK_TRANSFER 3 63#define GNUNET_APPLICATION_PORT_INTERNET_RESOLVER "exit-dns"
62 64
63/** 65/**
64 * Internet IPv4 gateway (any TCP/UDP/ICMP). 66 * Internet IPv4 gateway (any TCP/UDP/ICMP).
65 */ 67 */
66#define GNUNET_APPLICATION_TYPE_IPV4_GATEWAY 16 68#define GNUNET_APPLICATION_PORT_IPV4_GATEWAY "exit-ipv4"
67 69
68/** 70/**
69 * Internet IPv6 gateway (any TCP/UDP/ICMP). 71 * Internet IPv6 gateway (any TCP/UDP/ICMP).
70 */ 72 */
71#define GNUNET_APPLICATION_TYPE_IPV6_GATEWAY 17 73#define GNUNET_APPLICATION_PORT_IPV6_GATEWAY "exit-ipv6"
72 74
73/** 75/**
74 * Internet exit regex prefix. Consisting of application ID, followed by version 76 * Internet exit regex prefix. Consisting of application ID, followed
75 * and padding. 77 * by version and padding.
76 */ 78 */
77#define GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX "GNUNET-VPN-VER-0001-" 79#define GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX "GNUNET-VPN-VER-0001-"
78 80
79/** 81/**
80 * Consensus. 82 * Consensus.
83 *
84 * @deprecated
81 */ 85 */
82#define GNUNET_APPLICATION_TYPE_CONSENSUS 18 86#define GNUNET_APPLICATION_TYPE_CONSENSUS 18
83 87
84/** 88/**
85 * Set. Used for two-peer set operations implemented using stream. 89 * Set. Used for two-peer set operations implemented using stream.
90 * @deprecated
86 */ 91 */
87#define GNUNET_APPLICATION_TYPE_SET 19 92#define GNUNET_APPLICATION_TYPE_SET 19
88 93
89/** 94/**
90 * Vectorproduct. Used for two-peer scalarproduct operations
91 */
92#define GNUNET_APPLICATION_TYPE_SCALARPRODUCT 20
93
94/**
95 * Conversation control data. 95 * Conversation control data.
96 * @deprecated
96 */ 97 */
97#define GNUNET_APPLICATION_TYPE_CONVERSATION_CONTROL 21 98#define GNUNET_APPLICATION_TYPE_CONVERSATION_CONTROL 21
98 99
99/** 100/**
100 * Conversation audio data. 101 * Conversation audio data.
102 * @deprecated
101 */ 103 */
102#define GNUNET_APPLICATION_TYPE_CONVERSATION_AUDIO 22 104#define GNUNET_APPLICATION_TYPE_CONVERSATION_AUDIO 22
103 105
104/** 106/**
105 * MQTT publish-subscribe. 107 * MQTT publish-subscribe.
108 * @deprecated
106 */ 109 */
107#define GNUNET_APPLICATION_TYPE_MQTT 23 110#define GNUNET_APPLICATION_TYPE_MQTT 23
108 111
109/** 112/**
110 * Application receiving sensor measurements from peers
111 */
112#define GNUNET_APPLICATION_TYPE_SENSORDASHBOARD 24
113
114/**
115 * Application offering sensor updates
116 */
117#define GNUNET_APPLICATION_TYPE_SENSORUPDATE 25
118
119/**
120 * Multicast data. 113 * Multicast data.
114 * @deprecated
121 */ 115 */
122#define GNUNET_APPLICATION_TYPE_MULTICAST 26 116#define GNUNET_APPLICATION_TYPE_MULTICAST 26
123 117
124/**
125 * Vectorproduct, ECC variant. Used for two-peer scalarproduct operations
126 */
127#define GNUNET_APPLICATION_TYPE_SCALARPRODUCT_ECC 27
128 118
129#if 0 /* keep Emacsens' auto-indent happy */ 119#if 0 /* keep Emacsens' auto-indent happy */
130{ 120{
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index 5b2338998..cc42cac86 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -786,6 +786,7 @@ GNUNET_ntoh_double (double d);
786 */ 786 */
787#define GNUNET_memcpy(dst,src,n) do { if (0 != n) { (void) memcpy (dst,src,n); } } while (0) 787#define GNUNET_memcpy(dst,src,n) do { if (0 != n) { (void) memcpy (dst,src,n); } } while (0)
788 788
789
789/** 790/**
790 * @ingroup memory 791 * @ingroup memory
791 * Allocate a size @a n array with structs or unions of the given @a type. 792 * Allocate a size @a n array with structs or unions of the given @a type.
diff --git a/src/pt/gnunet-daemon-pt.c b/src/pt/gnunet-daemon-pt.c
index 7f4852e4b..443ff8ae6 100644
--- a/src/pt/gnunet-daemon-pt.c
+++ b/src/pt/gnunet-daemon-pt.c
@@ -333,7 +333,11 @@ try_open_exit ()
333 struct CadetExit *pos; 333 struct CadetExit *pos;
334 uint32_t candidate_count; 334 uint32_t candidate_count;
335 uint32_t candidate_selected; 335 uint32_t candidate_selected;
336 struct GNUNET_HashCode port;
336 337
338 GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_INTERNET_RESOLVER,
339 strlen (GNUNET_APPLICATION_PORT_INTERNET_RESOLVER),
340 &port);
337 candidate_count = 0; 341 candidate_count = 0;
338 for (pos = exit_head; NULL != pos; pos = pos->next) 342 for (pos = exit_head; NULL != pos; pos = pos->next)
339 if (NULL == pos->cadet_channel) 343 if (NULL == pos->cadet_channel)
@@ -348,11 +352,12 @@ try_open_exit ()
348 if (candidate_selected < candidate_count) 352 if (candidate_selected < candidate_count)
349 { 353 {
350 /* move to the head of the DLL */ 354 /* move to the head of the DLL */
351 pos->cadet_channel = GNUNET_CADET_channel_create (cadet_handle, 355 pos->cadet_channel
352 pos, 356 = GNUNET_CADET_channel_create (cadet_handle,
353 &pos->peer, 357 pos,
354 GC_u2h (GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER), 358 &pos->peer,
355 GNUNET_CADET_OPTION_DEFAULT); 359 &port,
360 GNUNET_CADET_OPTION_DEFAULT);
356 if (NULL == pos->cadet_channel) 361 if (NULL == pos->cadet_channel)
357 { 362 {
358 GNUNET_break (0); 363 GNUNET_break (0);
@@ -488,7 +493,8 @@ finish_request (struct ReplyContext *rc)
488 gettext_noop ("# DNS requests mapped to VPN"), 493 gettext_noop ("# DNS requests mapped to VPN"),
489 1, GNUNET_NO); 494 1, GNUNET_NO);
490 GNUNET_DNS_request_answer (rc->rh, 495 GNUNET_DNS_request_answer (rc->rh,
491 buf_len, buf); 496 buf_len,
497 buf);
492 GNUNET_free (buf); 498 GNUNET_free (buf);
493 } 499 }
494 GNUNET_DNSPARSER_free_packet (rc->dns); 500 GNUNET_DNSPARSER_free_packet (rc->dns);
@@ -539,16 +545,21 @@ vpn_allocation_callback (void *cls,
539 } 545 }
540 GNUNET_STATISTICS_update (stats, 546 GNUNET_STATISTICS_update (stats,
541 gettext_noop ("# DNS records modified"), 547 gettext_noop ("# DNS records modified"),
542 1, GNUNET_NO); 548 1,
549 GNUNET_NO);
543 switch (rc->rec->type) 550 switch (rc->rec->type)
544 { 551 {
545 case GNUNET_DNSPARSER_TYPE_A: 552 case GNUNET_DNSPARSER_TYPE_A:
546 GNUNET_assert (AF_INET == af); 553 GNUNET_assert (AF_INET == af);
547 GNUNET_memcpy (rc->rec->data.raw.data, address, sizeof (struct in_addr)); 554 GNUNET_memcpy (rc->rec->data.raw.data,
555 address,
556 sizeof (struct in_addr));
548 break; 557 break;
549 case GNUNET_DNSPARSER_TYPE_AAAA: 558 case GNUNET_DNSPARSER_TYPE_AAAA:
550 GNUNET_assert (AF_INET6 == af); 559 GNUNET_assert (AF_INET6 == af);
551 GNUNET_memcpy (rc->rec->data.raw.data, address, sizeof (struct in6_addr)); 560 GNUNET_memcpy (rc->rec->data.raw.data,
561 address,
562 sizeof (struct in6_addr));
552 break; 563 break;
553 default: 564 default:
554 GNUNET_assert (0); 565 GNUNET_assert (0);
@@ -590,7 +601,8 @@ modify_address (struct ReplyContext *rc,
590 } 601 }
591 rc->rec = rec; 602 rc->rec = rec;
592 rc->rr = GNUNET_VPN_redirect_to_ip (vpn_handle, 603 rc->rr = GNUNET_VPN_redirect_to_ip (vpn_handle,
593 af, af, 604 af,
605 af,
594 rec->data.raw.data, 606 rec->data.raw.data,
595 GNUNET_TIME_relative_to_absolute (TIMEOUT), 607 GNUNET_TIME_relative_to_absolute (TIMEOUT),
596 &vpn_allocation_callback, 608 &vpn_allocation_callback,
@@ -642,7 +654,8 @@ submit_request (struct ReplyContext *rc)
642 if (ipv4_pt) 654 if (ipv4_pt)
643 { 655 {
644 rc->offset = i + 1; 656 rc->offset = i + 1;
645 modify_address (rc, &ra[i]); 657 modify_address (rc,
658 &ra[i]);
646 return; 659 return;
647 } 660 }
648 break; 661 break;
@@ -650,7 +663,8 @@ submit_request (struct ReplyContext *rc)
650 if (ipv6_pt) 663 if (ipv6_pt)
651 { 664 {
652 rc->offset = i + 1; 665 rc->offset = i + 1;
653 modify_address (rc, &ra[i]); 666 modify_address (rc,
667 &ra[i]);
654 return; 668 return;
655 } 669 }
656 break; 670 break;
@@ -716,7 +730,8 @@ dns_post_request_handler (void *cls,
716 GNUNET_STATISTICS_update (stats, 730 GNUNET_STATISTICS_update (stats,
717 gettext_noop ("# DNS replies intercepted"), 731 gettext_noop ("# DNS replies intercepted"),
718 1, GNUNET_NO); 732 1, GNUNET_NO);
719 dns = GNUNET_DNSPARSER_parse (request, request_length); 733 dns = GNUNET_DNSPARSER_parse (request,
734 request_length);
720 if (NULL == dns) 735 if (NULL == dns)
721 { 736 {
722 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 737 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -725,9 +740,12 @@ dns_post_request_handler (void *cls,
725 return; 740 return;
726 } 741 }
727 work = GNUNET_NO; 742 work = GNUNET_NO;
728 work |= work_test (dns->answers, dns->num_answers); 743 work |= work_test (dns->answers,
729 work |= work_test (dns->authority_records, dns->num_authority_records); 744 dns->num_answers);
730 work |= work_test (dns->additional_records, dns->num_additional_records); 745 work |= work_test (dns->authority_records,
746 dns->num_authority_records);
747 work |= work_test (dns->additional_records,
748 dns->num_additional_records);
731 if (! work) 749 if (! work)
732 { 750 {
733 GNUNET_DNS_request_forward (rh); 751 GNUNET_DNS_request_forward (rh);
@@ -767,16 +785,19 @@ transmit_dns_request_to_cadet (void *cls,
767 mlen = rc->mlen; 785 mlen = rc->mlen;
768 if (mlen > size) 786 if (mlen > size)
769 { 787 {
770 exit->cadet_th = GNUNET_CADET_notify_transmit_ready (exit->cadet_channel, 788 exit->cadet_th
771 GNUNET_NO, 789 = GNUNET_CADET_notify_transmit_ready (exit->cadet_channel,
772 TIMEOUT, 790 GNUNET_NO,
773 mlen, 791 TIMEOUT,
774 &transmit_dns_request_to_cadet, 792 mlen,
775 exit); 793 &transmit_dns_request_to_cadet,
794 exit);
776 return 0; 795 return 0;
777 } 796 }
778 GNUNET_assert (GNUNET_NO == rc->was_transmitted); 797 GNUNET_assert (GNUNET_NO == rc->was_transmitted);
779 GNUNET_memcpy (buf, rc->cadet_message, mlen); 798 GNUNET_memcpy (buf,
799 rc->cadet_message,
800 mlen);
780 GNUNET_CONTAINER_DLL_remove (exit->transmit_queue_head, 801 GNUNET_CONTAINER_DLL_remove (exit->transmit_queue_head,
781 exit->transmit_queue_tail, 802 exit->transmit_queue_tail,
782 rc); 803 rc);
@@ -822,7 +843,8 @@ timeout_request (void *cls)
822 } 843 }
823 GNUNET_STATISTICS_update (stats, 844 GNUNET_STATISTICS_update (stats,
824 gettext_noop ("# DNS requests dropped (timeout)"), 845 gettext_noop ("# DNS requests dropped (timeout)"),
825 1, GNUNET_NO); 846 1,
847 GNUNET_NO);
826 GNUNET_DNS_request_drop (rc->rh); 848 GNUNET_DNS_request_drop (rc->rh);
827 GNUNET_free (rc); 849 GNUNET_free (rc);
828 if ( (0 == get_channel_weight (exit)) && 850 if ( (0 == get_channel_weight (exit)) &&
@@ -1148,12 +1170,13 @@ cadet_channel_end_cb (void *cls,
1148 } 1170 }
1149 if ( (NULL == alt->cadet_th) && 1171 if ( (NULL == alt->cadet_th) &&
1150 (NULL != (rc = alt->transmit_queue_head)) ) 1172 (NULL != (rc = alt->transmit_queue_head)) )
1151 alt->cadet_th = GNUNET_CADET_notify_transmit_ready (alt->cadet_channel, 1173 alt->cadet_th
1152 GNUNET_NO, 1174 = GNUNET_CADET_notify_transmit_ready (alt->cadet_channel,
1153 TIMEOUT, 1175 GNUNET_NO,
1154 rc->mlen, 1176 TIMEOUT,
1155 &transmit_dns_request_to_cadet, 1177 rc->mlen,
1156 alt); 1178 &transmit_dns_request_to_cadet,
1179 alt);
1157} 1180}
1158 1181
1159 1182
@@ -1233,10 +1256,17 @@ run (void *cls, char *const *args GNUNET_UNUSED,
1233 struct GNUNET_HashCode dns_key; 1256 struct GNUNET_HashCode dns_key;
1234 1257
1235 cfg = cfg_; 1258 cfg = cfg_;
1236 stats = GNUNET_STATISTICS_create ("pt", cfg); 1259 stats = GNUNET_STATISTICS_create ("pt",
1237 ipv4_pt = GNUNET_CONFIGURATION_get_value_yesno (cfg, "pt", "TUNNEL_IPV4"); 1260 cfg);
1238 ipv6_pt = GNUNET_CONFIGURATION_get_value_yesno (cfg, "pt", "TUNNEL_IPV6"); 1261 ipv4_pt = GNUNET_CONFIGURATION_get_value_yesno (cfg,
1239 dns_channel = GNUNET_CONFIGURATION_get_value_yesno (cfg, "pt", "TUNNEL_DNS"); 1262 "pt",
1263 "TUNNEL_IPV4");
1264 ipv6_pt = GNUNET_CONFIGURATION_get_value_yesno (cfg,
1265 "pt",
1266 "TUNNEL_IPV6");
1267 dns_channel = GNUNET_CONFIGURATION_get_value_yesno (cfg,
1268 "pt",
1269 "TUNNEL_DNS");
1240 if (! (ipv4_pt || ipv6_pt || dns_channel)) 1270 if (! (ipv4_pt || ipv6_pt || dns_channel))
1241 { 1271 {
1242 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1272 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1250,7 +1280,8 @@ run (void *cls, char *const *args GNUNET_UNUSED,
1250 dns_post_handle 1280 dns_post_handle
1251 = GNUNET_DNS_connect (cfg, 1281 = GNUNET_DNS_connect (cfg,
1252 GNUNET_DNS_FLAG_POST_RESOLUTION, 1282 GNUNET_DNS_FLAG_POST_RESOLUTION,
1253 &dns_post_request_handler, NULL); 1283 &dns_post_request_handler,
1284 NULL);
1254 if (NULL == dns_post_handle) 1285 if (NULL == dns_post_handle)
1255 { 1286 {
1256 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1287 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1279,7 +1310,8 @@ run (void *cls, char *const *args GNUNET_UNUSED,
1279 dns_pre_handle 1310 dns_pre_handle
1280 = GNUNET_DNS_connect (cfg, 1311 = GNUNET_DNS_connect (cfg,
1281 GNUNET_DNS_FLAG_PRE_RESOLUTION, 1312 GNUNET_DNS_FLAG_PRE_RESOLUTION,
1282 &dns_pre_request_handler, NULL); 1313 &dns_pre_request_handler,
1314 NULL);
1283 if (NULL == dns_pre_handle) 1315 if (NULL == dns_pre_handle)
1284 { 1316 {
1285 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1317 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1288,9 +1320,10 @@ run (void *cls, char *const *args GNUNET_UNUSED,
1288 GNUNET_SCHEDULER_shutdown (); 1320 GNUNET_SCHEDULER_shutdown ();
1289 return; 1321 return;
1290 } 1322 }
1291 cadet_handle = GNUNET_CADET_connect (cfg, NULL, 1323 cadet_handle = GNUNET_CADET_connect (cfg,
1292 &cadet_channel_end_cb, 1324 NULL,
1293 cadet_handlers); 1325 &cadet_channel_end_cb,
1326 cadet_handlers);
1294 if (NULL == cadet_handle) 1327 if (NULL == cadet_handle)
1295 { 1328 {
1296 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1329 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1308,14 +1341,17 @@ run (void *cls, char *const *args GNUNET_UNUSED,
1308 GNUNET_SCHEDULER_shutdown (); 1341 GNUNET_SCHEDULER_shutdown ();
1309 return; 1342 return;
1310 } 1343 }
1311 GNUNET_CRYPTO_hash ("dns", strlen ("dns"), &dns_key); 1344 GNUNET_CRYPTO_hash ("dns",
1345 strlen ("dns"),
1346 &dns_key);
1312 dht_get = GNUNET_DHT_get_start (dht, 1347 dht_get = GNUNET_DHT_get_start (dht,
1313 GNUNET_BLOCK_TYPE_DNS, 1348 GNUNET_BLOCK_TYPE_DNS,
1314 &dns_key, 1349 &dns_key,
1315 1, 1350 1,
1316 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, 1351 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
1317 NULL, 0, 1352 NULL, 0,
1318 &handle_dht_result, NULL); 1353 &handle_dht_result,
1354 NULL);
1319 } 1355 }
1320} 1356}
1321 1357
@@ -1328,20 +1364,29 @@ run (void *cls, char *const *args GNUNET_UNUSED,
1328 * @return 0 ok, 1 on error 1364 * @return 0 ok, 1 on error
1329 */ 1365 */
1330int 1366int
1331main (int argc, char *const *argv) 1367main (int argc,
1368 char *const *argv)
1332{ 1369{
1333 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 1370 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
1334 GNUNET_GETOPT_OPTION_END 1371 GNUNET_GETOPT_OPTION_END
1335 }; 1372 };
1336 int ret; 1373 int ret;
1337 1374
1338 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 1375 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc,
1376 argv,
1377 &argc,
1378 &argv))
1339 return 2; 1379 return 2;
1340 ret = (GNUNET_OK == 1380 ret = (GNUNET_OK ==
1341 GNUNET_PROGRAM_run (argc, argv, "gnunet-daemon-pt", 1381 GNUNET_PROGRAM_run (argc,
1342 gettext_noop 1382 argv,
1343 ("Daemon to run to perform IP protocol translation to GNUnet"), 1383 "gnunet-daemon-pt",
1344 options, &run, NULL)) ? 0 : 1; 1384 gettext_noop ("Daemon to run to perform IP protocol translation to GNUnet"),
1385 options,
1386 &run,
1387 NULL))
1388 ? 0
1389 : 1;
1345 GNUNET_free ((void*) argv); 1390 GNUNET_free ((void*) argv);
1346 return ret; 1391 return ret;
1347} 1392}
diff --git a/src/testbed/gnunet-service-testbed_barriers.c b/src/testbed/gnunet-service-testbed_barriers.c
index b994a7d15..c3ae82ed8 100644
--- a/src/testbed/gnunet-service-testbed_barriers.c
+++ b/src/testbed/gnunet-service-testbed_barriers.c
@@ -862,7 +862,8 @@ GST_handle_barrier_cancel (void *cls, struct GNUNET_SERVER_Client *client,
862 * @param message the actual message 862 * @param message the actual message
863 */ 863 */
864void 864void
865GST_handle_barrier_status (void *cls, struct GNUNET_SERVER_Client *client, 865GST_handle_barrier_status (void *cls,
866 struct GNUNET_SERVER_Client *client,
866 const struct GNUNET_MessageHeader *message) 867 const struct GNUNET_MessageHeader *message)
867{ 868{
868 const struct GNUNET_TESTBED_BarrierStatusMsg *msg; 869 const struct GNUNET_TESTBED_BarrierStatusMsg *msg;
diff --git a/src/util/crypto_kdf.c b/src/util/crypto_kdf.c
index 2617e9a7d..78fb1911a 100644
--- a/src/util/crypto_kdf.c
+++ b/src/util/crypto_kdf.c
@@ -44,9 +44,12 @@
44 * @return #GNUNET_YES on success 44 * @return #GNUNET_YES on success
45 */ 45 */
46int 46int
47GNUNET_CRYPTO_kdf_v (void *result, size_t out_len, 47GNUNET_CRYPTO_kdf_v (void *result,
48 const void *xts, size_t xts_len, 48 size_t out_len,
49 const void *skm, size_t skm_len, 49 const void *xts,
50 size_t xts_len,
51 const void *skm,
52 size_t skm_len,
50 va_list argp) 53 va_list argp)
51{ 54{
52 /* 55 /*
@@ -61,8 +64,15 @@ GNUNET_CRYPTO_kdf_v (void *result, size_t out_len,
61 * http://eprint.iacr.org/2010/264 64 * http://eprint.iacr.org/2010/264
62 */ 65 */
63 66
64 return GNUNET_CRYPTO_hkdf_v (result, out_len, GCRY_MD_SHA512, GCRY_MD_SHA256, 67 return GNUNET_CRYPTO_hkdf_v (result,
65 xts, xts_len, skm, skm_len, argp); 68 out_len,
69 GCRY_MD_SHA512,
70 GCRY_MD_SHA256,
71 xts,
72 xts_len,
73 skm,
74 skm_len,
75 argp);
66} 76}
67 77
68 78
@@ -78,15 +88,24 @@ GNUNET_CRYPTO_kdf_v (void *result, size_t out_len,
78 * @return #GNUNET_YES on success 88 * @return #GNUNET_YES on success
79 */ 89 */
80int 90int
81GNUNET_CRYPTO_kdf (void *result, size_t out_len, 91GNUNET_CRYPTO_kdf (void *result,
82 const void *xts, size_t xts_len, 92 size_t out_len,
83 const void *skm, size_t skm_len, ...) 93 const void *xts,
94 size_t xts_len,
95 const void *skm,
96 size_t skm_len, ...)
84{ 97{
85 va_list argp; 98 va_list argp;
86 int ret; 99 int ret;
87 100
88 va_start (argp, skm_len); 101 va_start (argp, skm_len);
89 ret = GNUNET_CRYPTO_kdf_v (result, out_len, xts, xts_len, skm, skm_len, argp); 102 ret = GNUNET_CRYPTO_kdf_v (result,
103 out_len,
104 xts,
105 xts_len,
106 skm,
107 skm_len,
108 argp);
90 va_end (argp); 109 va_end (argp);
91 110
92 return ret; 111 return ret;
@@ -151,3 +170,5 @@ GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
151 gcry_mpi_release (*r); 170 gcry_mpi_release (*r);
152 } 171 }
153} 172}
173
174/* end of crypto_kdf.c */
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c
index 812016205..785bf7be1 100644
--- a/src/vpn/gnunet-service-vpn.c
+++ b/src/vpn/gnunet-service-vpn.c
@@ -622,12 +622,15 @@ send_to_peer_notify_callback (void *cls, size_t size, void *buf)
622 ret = tnq->len; 622 ret = tnq->len;
623 GNUNET_free (tnq); 623 GNUNET_free (tnq);
624 if (NULL != (tnq = ts->tmq_head)) 624 if (NULL != (tnq = ts->tmq_head))
625 ts->th = GNUNET_CADET_notify_transmit_ready (ts->channel, 625 {
626 GNUNET_NO /* cork */, 626 if (NULL == ts->th)
627 GNUNET_TIME_UNIT_FOREVER_REL, 627 ts->th = GNUNET_CADET_notify_transmit_ready (ts->channel,
628 tnq->len, 628 GNUNET_NO /* cork */,
629 &send_to_peer_notify_callback, 629 GNUNET_TIME_UNIT_FOREVER_REL,
630 ts); 630 tnq->len,
631 &send_to_peer_notify_callback,
632 ts);
633 }
631 GNUNET_STATISTICS_update (stats, 634 GNUNET_STATISTICS_update (stats,
632 gettext_noop ("# Bytes given to cadet for transmission"), 635 gettext_noop ("# Bytes given to cadet for transmission"),
633 ret, GNUNET_NO); 636 ret, GNUNET_NO);
@@ -731,7 +734,7 @@ handle_regex_result (void *cls,
731 unsigned int put_path_length) 734 unsigned int put_path_length)
732{ 735{
733 struct ChannelState *ts = cls; 736 struct ChannelState *ts = cls;
734 unsigned int apptype; 737 struct GNUNET_HashCode port;
735 738
736 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 739 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
737 "Exit %s found for destination %s!\n", 740 "Exit %s found for destination %s!\n",
@@ -742,10 +745,16 @@ handle_regex_result (void *cls,
742 switch (ts->af) 745 switch (ts->af)
743 { 746 {
744 case AF_INET: 747 case AF_INET:
745 apptype = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY; 748 /* these must match the strings used in gnunet-daemon-exit */
749 GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_IPV4_GATEWAY,
750 strlen (GNUNET_APPLICATION_PORT_IPV4_GATEWAY),
751 &port);
746 break; 752 break;
747 case AF_INET6: 753 case AF_INET6:
748 apptype = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY; 754 /* these must match the strings used in gnunet-daemon-exit */
755 GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_IPV6_GATEWAY,
756 strlen (GNUNET_APPLICATION_PORT_IPV6_GATEWAY),
757 &port);
749 break; 758 break;
750 default: 759 default:
751 GNUNET_break (0); 760 GNUNET_break (0);
@@ -758,7 +767,7 @@ handle_regex_result (void *cls,
758 ts->channel = GNUNET_CADET_channel_create (cadet_handle, 767 ts->channel = GNUNET_CADET_channel_create (cadet_handle,
759 ts, 768 ts,
760 id, 769 id,
761 GC_u2h (apptype), 770 &port,
762 GNUNET_CADET_OPTION_DEFAULT); 771 GNUNET_CADET_OPTION_DEFAULT);
763} 772}
764 773
@@ -775,23 +784,11 @@ create_channel_to_destination (struct DestinationChannel *dt,
775 int client_af) 784 int client_af)
776{ 785{
777 struct ChannelState *ts; 786 struct ChannelState *ts;
778 unsigned int apptype;
779 787
780 GNUNET_STATISTICS_update (stats, 788 GNUNET_STATISTICS_update (stats,
781 gettext_noop ("# Cadet channels created"), 789 gettext_noop ("# Cadet channels created"),
782 1, GNUNET_NO); 790 1,
783 switch (client_af) 791 GNUNET_NO);
784 {
785 case AF_INET:
786 apptype = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY;
787 break;
788 case AF_INET6:
789 apptype = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY;
790 break;
791 default:
792 GNUNET_break (0);
793 return NULL;
794 }
795 ts = GNUNET_new (struct ChannelState); 792 ts = GNUNET_new (struct ChannelState);
796 ts->af = client_af; 793 ts->af = client_af;
797 ts->destination = *dt->destination; 794 ts->destination = *dt->destination;
@@ -801,12 +798,11 @@ create_channel_to_destination (struct DestinationChannel *dt,
801 ts->channel = GNUNET_CADET_channel_create (cadet_handle, 798 ts->channel = GNUNET_CADET_channel_create (cadet_handle,
802 ts, 799 ts,
803 &dt->destination->details.service_destination.target, 800 &dt->destination->details.service_destination.target,
804 GC_u2h (apptype), 801 &ts->destination.details.service_destination.service_descriptor,
805 GNUNET_CADET_OPTION_DEFAULT); 802 GNUNET_CADET_OPTION_DEFAULT);
806 if (NULL == ts->channel) 803 if (NULL == ts->channel)
807 { 804 {
808 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 805 GNUNET_break (0);
809 _("Failed to setup cadet channel!\n"));
810 GNUNET_free (ts); 806 GNUNET_free (ts);
811 return NULL; 807 return NULL;
812 } 808 }
@@ -1032,9 +1028,15 @@ route_packet (struct DestinationEntry *destination,
1032 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1028 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1033 "Routing %s packet from [%s]:%u -> [%s]:%u to destination [%s]:%u\n", 1029 "Routing %s packet from [%s]:%u -> [%s]:%u to destination [%s]:%u\n",
1034 (protocol == IPPROTO_TCP) ? "TCP" : "UDP", 1030 (protocol == IPPROTO_TCP) ? "TCP" : "UDP",
1035 inet_ntop (af, source_ip, sbuf, sizeof (sbuf)), 1031 inet_ntop (af,
1032 source_ip,
1033 sbuf,
1034 sizeof (sbuf)),
1036 source_port, 1035 source_port,
1037 inet_ntop (af, destination_ip, dbuf, sizeof (dbuf)), 1036 inet_ntop (af,
1037 destination_ip,
1038 dbuf,
1039 sizeof (dbuf)),
1038 destination_port, 1040 destination_port,
1039 inet_ntop (destination->details.exit_destination.af, 1041 inet_ntop (destination->details.exit_destination.af,
1040 &destination->details.exit_destination.ip, 1042 &destination->details.exit_destination.ip,
@@ -1054,9 +1056,15 @@ route_packet (struct DestinationEntry *destination,
1054 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1056 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1055 "Routing %s packet from [%s]:%u -> [%s]:%u to service %s at peer %s\n", 1057 "Routing %s packet from [%s]:%u -> [%s]:%u to service %s at peer %s\n",
1056 (protocol == IPPROTO_TCP) ? "TCP" : "UDP", 1058 (protocol == IPPROTO_TCP) ? "TCP" : "UDP",
1057 inet_ntop (af, source_ip, sbuf, sizeof (sbuf)), 1059 inet_ntop (af,
1060 source_ip,
1061 sbuf,
1062 sizeof (sbuf)),
1058 source_port, 1063 source_port,
1059 inet_ntop (af, destination_ip, dbuf, sizeof (dbuf)), 1064 inet_ntop (af,
1065 destination_ip,
1066 dbuf,
1067 sizeof (dbuf)),
1060 destination_port, 1068 destination_port,
1061 GNUNET_h2s (&destination->details.service_destination.service_descriptor), 1069 GNUNET_h2s (&destination->details.service_destination.service_descriptor),
1062 GNUNET_i2s (&destination->details.service_destination.target)); 1070 GNUNET_i2s (&destination->details.service_destination.target));
@@ -1163,8 +1171,8 @@ route_packet (struct DestinationEntry *destination,
1163 usm->destination_port = udp->destination_port; 1171 usm->destination_port = udp->destination_port;
1164 usm->service_descriptor = destination->details.service_destination.service_descriptor; 1172 usm->service_descriptor = destination->details.service_destination.service_descriptor;
1165 GNUNET_memcpy (&usm[1], 1173 GNUNET_memcpy (&usm[1],
1166 &udp[1], 1174 &udp[1],
1167 payload_length - sizeof (struct GNUNET_TUN_UdpHeader)); 1175 payload_length - sizeof (struct GNUNET_TUN_UdpHeader));
1168 } 1176 }
1169 else 1177 else
1170 { 1178 {
@@ -1233,8 +1241,8 @@ route_packet (struct DestinationEntry *destination,
1233 tsm->service_descriptor = destination->details.service_destination.service_descriptor; 1241 tsm->service_descriptor = destination->details.service_destination.service_descriptor;
1234 tsm->tcp_header = *tcp; 1242 tsm->tcp_header = *tcp;
1235 GNUNET_memcpy (&tsm[1], 1243 GNUNET_memcpy (&tsm[1],
1236 &tcp[1], 1244 &tcp[1],
1237 payload_length - sizeof (struct GNUNET_TUN_TcpHeader)); 1245 payload_length - sizeof (struct GNUNET_TUN_TcpHeader));
1238 } 1246 }
1239 else 1247 else
1240 { 1248 {
@@ -2760,7 +2768,10 @@ service_redirect_to_service (void *cls,
2760 2768
2761 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2769 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2762 "Allocated address %s for redirection to service %s on peer %s\n", 2770 "Allocated address %s for redirection to service %s on peer %s\n",
2763 inet_ntop (result_af, addr, sbuf, sizeof (sbuf)), 2771 inet_ntop (result_af,
2772 addr,
2773 sbuf,
2774 sizeof (sbuf)),
2764 GNUNET_h2s (&msg->service_descriptor), 2775 GNUNET_h2s (&msg->service_descriptor),
2765 GNUNET_i2s (&msg->target)); 2776 GNUNET_i2s (&msg->target));
2766 } 2777 }
diff --git a/src/vpn/vpn_api.c b/src/vpn/vpn_api.c
index 42fe7d4b4..ad0b5e9f0 100644
--- a/src/vpn/vpn_api.c
+++ b/src/vpn/vpn_api.c
@@ -279,8 +279,8 @@ send_request (struct GNUNET_VPN_RedirectionRequest *rr)
279 rip->addr_af = htonl (rr->addr_af); 279 rip->addr_af = htonl (rr->addr_af);
280 rip->request_id = rr->request_id = ++vh->request_id_gen; 280 rip->request_id = rr->request_id = ++vh->request_id_gen;
281 GNUNET_memcpy (&rip[1], 281 GNUNET_memcpy (&rip[1],
282 rr->addr, 282 rr->addr,
283 alen); 283 alen);
284 } 284 }
285 GNUNET_MQ_send (vh->mq, 285 GNUNET_MQ_send (vh->mq,
286 env); 286 env);