sizeof (struct GNUNET_DNS_Advertisement),
&dns_advertisement,
expiration,
- &dht_put_cont, NULL);
+ &dht_put_cont,
+ NULL);
}
/**
- * @brief Main function that will be run by the scheduler.
- *
- * @param cls closure
- * @param args remaining command-line arguments
- * @param cfgfile name of the configuration file used (for saving, can be NULL!)
- * @param cfg_ configuration
+ * Figure out which IP versions we should support (and which
+ * are supported by the OS) according to our configuration.
*/
static void
-run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg_)
+parse_ip_options ()
{
- static struct GNUNET_CADET_MessageHandler handlers[] = {
- {&receive_icmp_service, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE, 0},
- {&receive_icmp_remote, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_INTERNET, 0},
- {&receive_udp_service, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE, 0},
- {&receive_udp_remote, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET, 0},
- {&receive_tcp_service, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START, 0},
- {&receive_tcp_remote, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START, 0},
- {&receive_tcp_data, GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_EXIT, 0},
- {&receive_dns_request, GNUNET_MESSAGE_TYPE_VPN_DNS_TO_INTERNET, 0},
- {NULL, 0, 0}
- };
-
- static uint32_t apptypes[] = {
- GNUNET_APPLICATION_TYPE_END,
- GNUNET_APPLICATION_TYPE_END,
- GNUNET_APPLICATION_TYPE_END,
- GNUNET_APPLICATION_TYPE_END
- };
- unsigned int app_idx;
- char *exit_ifname;
- char *tun_ifname;
- char *policy;
- char *ipv6addr;
- char *ipv6prefix_s;
- char *ipv4addr;
- char *ipv4mask;
- char *binary;
- char *regex;
- char *prefixed_regex;
- struct in_addr dns_exit4;
- struct in6_addr dns_exit6;
- char *dns_exit;
-
- cfg = cfg_;
- ipv4_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "EXIT_IPV4");
- ipv6_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "EXIT_IPV6");
- ipv4_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV4");
- ipv6_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, "exit", "ENABLE_IPV6");
- if ( (ipv4_exit) || (ipv6_exit) )
- {
- binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit");
- if (GNUNET_YES !=
- GNUNET_OS_check_helper_binary (binary, GNUNET_YES, "-d gnunet-vpn - - - 169.1.3.3.7 255.255.255.0")) //no nat, ipv4 only
- {
- GNUNET_free (binary);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("`%s' must be installed SUID, EXIT will not work\n"),
- "gnunet-helper-exit");
- GNUNET_SCHEDULER_add_shutdown (&dummy_task,
- NULL);
- global_ret = 1;
- return;
- }
- GNUNET_free (binary);
- }
- stats = GNUNET_STATISTICS_create ("exit", cfg);
-
+ ipv4_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+ "exit",
+ "EXIT_IPV4");
+ ipv6_exit = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+ "exit",
+ "EXIT_IPV6");
+ ipv4_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+ "exit",
+ "ENABLE_IPV4");
+ ipv6_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+ "exit",
+ "ENABLE_IPV6");
if ( (ipv4_exit || ipv4_enabled) &&
GNUNET_OK != GNUNET_NETWORK_test_pf (PF_INET))
{
_("Cannot enable IPv6 exit but disable IPv6 on TUN interface, will use ENABLE_IPv6=YES\n"));
ipv6_enabled = GNUNET_YES;
}
- if (! (ipv4_enabled || ipv6_enabled))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("No useful service enabled. Exiting.\n"));
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
+}
+
+
+/**
+ * Helper function to open the CADET port for DNS exits and to
+ * advertise the DNS exit (if applicable).
+ */
+static void
+advertise_dns_exit ()
+{
+ char *dns_exit;
+ struct GNUNET_HashCode port;
+ struct in_addr dns_exit4;
+ struct in6_addr dns_exit6;
- dns_exit = NULL;
- if ( (GNUNET_YES ==
- GNUNET_CONFIGURATION_get_value_yesno (cfg_, "exit", "EXIT_DNS")) &&
- ( (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (cfg, "exit",
- "DNS_RESOLVER",
- &dns_exit)) ||
- ( (1 != inet_pton (AF_INET, dns_exit, &dns_exit4)) &&
- (1 != inet_pton (AF_INET6, dns_exit, &dns_exit6)) ) ) )
+ if (GNUNET_YES !=
+ GNUNET_CONFIGURATION_get_value_yesno (cfg,
+ "exit",
+ "EXIT_DNS"))
+ return;
+ if ( (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ "exit",
+ "DNS_RESOLVER",
+ &dns_exit)) ||
+ ( (1 != inet_pton (AF_INET,
+ dns_exit,
+ &dns_exit4)) &&
+ (1 != inet_pton (AF_INET6,
+ dns_exit,
+ &dns_exit6)) ) )
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
- "dns", "DNS_RESOLVER",
+ "dns",
+ "DNS_RESOLVER",
_("need a valid IPv4 or IPv6 address\n"));
- GNUNET_free_non_null (dns_exit);
- dns_exit = NULL;
- }
- app_idx = 0;
- if (GNUNET_YES == ipv4_exit)
- {
- apptypes[app_idx] = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY;
- app_idx++;
- }
- if (GNUNET_YES == ipv6_exit)
- {
- apptypes[app_idx] = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY;
- app_idx++;
- }
- if (NULL != dns_exit)
- {
- dht = GNUNET_DHT_connect (cfg, 1);
- peer_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg);
- GNUNET_CRYPTO_eddsa_key_get_public (peer_key,
- &dns_advertisement.peer.public_key);
- dns_advertisement.purpose.size = htonl (sizeof (struct GNUNET_DNS_Advertisement) -
- sizeof (struct GNUNET_CRYPTO_EddsaSignature));
- dns_advertisement.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DNS_RECORD);
- GNUNET_CRYPTO_hash ("dns",
- strlen ("dns"),
- &dht_put_key);
- dht_task = GNUNET_SCHEDULER_add_now (&do_dht_put,
- NULL);
- apptypes[app_idx] = GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER;
- app_idx++;
- }
- GNUNET_free_non_null (dns_exit);
- GNUNET_SCHEDULER_add_shutdown (&cleanup,
- NULL);
+ return;
+ }
+ /* open port */
+ GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_INTERNET_RESOLVER,
+ strlen (GNUNET_APPLICATION_PORT_INTERNET_RESOLVER),
+ &port);
+ GNUNET_CADET_open_port (cadet_handle,
+ &port,
+ &new_channel,
+ NULL);
+ /* advertise exit */
+ dht = GNUNET_DHT_connect (cfg,
+ 1);
+ peer_key = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg);
+ GNUNET_CRYPTO_eddsa_key_get_public (peer_key,
+ &dns_advertisement.peer.public_key);
+ dns_advertisement.purpose.size = htonl (sizeof (struct GNUNET_DNS_Advertisement) -
+ sizeof (struct GNUNET_CRYPTO_EddsaSignature));
+ dns_advertisement.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DNS_RECORD);
+ GNUNET_CRYPTO_hash ("dns",
+ strlen ("dns"),
+ &dht_put_key);
+ dht_task = GNUNET_SCHEDULER_add_now (&do_dht_put,
+ NULL);
+ GNUNET_free (dns_exit);
+}
+
+
+/**
+ * Initialize #exit_argv.
+ *
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR if we should shutdown
+ */
+static int
+setup_exit_helper_args ()
+{
+ char *exit_ifname;
+ char *tun_ifname;
+ char *ipv6addr;
+ char *ipv6prefix_s;
+ char *ipv4addr;
+ char *ipv4mask;
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg, "exit", "MAX_CONNECTIONS",
- &max_connections))
- max_connections = 1024;
exit_argv[0] = GNUNET_strdup ("exit-gnunet");
if (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "TUN_IFNAME", &tun_ifname))
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ "exit",
+ "TUN_IFNAME",
+ &tun_ifname))
{
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "TUN_IFNAME");
- GNUNET_SCHEDULER_shutdown ();
- return;
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "EXIT",
+ "TUN_IFNAME");
+ return GNUNET_SYSERR;
}
exit_argv[1] = tun_ifname;
if (ipv4_enabled)
{
if (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "EXIT_IFNAME", &exit_ifname))
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ "exit",
+ "EXIT_IFNAME",
+ &exit_ifname))
{
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "EXIT_IFNAME");
- GNUNET_SCHEDULER_shutdown ();
- return;
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "EXIT",
+ "EXIT_IFNAME");
+ return GNUNET_SYSERR;
}
exit_argv[2] = exit_ifname;
}
exit_argv[2] = GNUNET_strdup ("-");
}
-
if (GNUNET_YES == ipv6_enabled)
{
ipv6addr = NULL;
"exit",
"IPV6ADDR",
&ipv6addr) ||
- (1 != inet_pton (AF_INET6, ipv6addr, &exit_ipv6addr))) )
+ (1 != inet_pton (AF_INET6,
+ ipv6addr,
+ &exit_ipv6addr))) )
{
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV6ADDR");
- GNUNET_SCHEDULER_shutdown ();
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "EXIT",
+ "IPV6ADDR");
GNUNET_free_non_null (ipv6addr);
- return;
+ return GNUNET_SYSERR;
}
exit_argv[3] = ipv6addr;
if (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV6PREFIX",
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ "exit",
+ "IPV6PREFIX",
&ipv6prefix_s))
{
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV6PREFIX");
- GNUNET_SCHEDULER_shutdown ();
- return;
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "EXIT",
+ "IPV6PREFIX");
+ return GNUNET_SYSERR;
}
exit_argv[4] = ipv6prefix_s;
if ( (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg, "exit",
+ GNUNET_CONFIGURATION_get_value_number (cfg,
+ "exit",
"IPV6PREFIX",
&ipv6prefix)) ||
(ipv6prefix >= 127) )
{
- GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV6PREFIX",
+ GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
+ "EXIT",
+ "IPV6PREFIX",
_("Must be a number"));
- GNUNET_SCHEDULER_shutdown ();
- return;
+ return GNUNET_SYSERR;
}
}
else
{
ipv4addr = NULL;
if ( (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4ADDR",
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ "exit",
+ "IPV4ADDR",
&ipv4addr) ||
- (1 != inet_pton (AF_INET, ipv4addr, &exit_ipv4addr))) )
+ (1 != inet_pton (AF_INET,
+ ipv4addr,
+ &exit_ipv4addr))) )
{
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV4ADDR");
- GNUNET_SCHEDULER_shutdown ();
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "EXIT",
+ "IPV4ADDR");
GNUNET_free_non_null (ipv4addr);
- return;
+ return GNUNET_SYSERR;
}
exit_argv[5] = ipv4addr;
ipv4mask = NULL;
if ( (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4MASK",
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ "exit",
+ "IPV4MASK",
&ipv4mask) ||
- (1 != inet_pton (AF_INET, ipv4mask, &exit_ipv4mask))) )
+ (1 != inet_pton (AF_INET,
+ ipv4mask,
+ &exit_ipv4mask))) )
{
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV4MASK");
- GNUNET_SCHEDULER_shutdown ();
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "EXIT",
+ "IPV4MASK");
GNUNET_free_non_null (ipv4mask);
- return;
+ return GNUNET_SYSERR;
}
exit_argv[6] = ipv4mask;
}
exit_argv[6] = GNUNET_strdup ("-");
}
exit_argv[7] = NULL;
+ return GNUNET_OK;
+}
- udp_services = GNUNET_CONTAINER_multihashmap_create (65536, GNUNET_NO);
- tcp_services = GNUNET_CONTAINER_multihashmap_create (65536, GNUNET_NO);
- GNUNET_CONFIGURATION_iterate_sections (cfg, &read_service_conf, NULL);
- connections_map = GNUNET_CONTAINER_multihashmap_create (65536, GNUNET_NO);
- connections_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
- if (0 == app_idx)
+/**
+ * @brief Main function that will be run by the scheduler.
+ *
+ * @param cls closure
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be NULL!)
+ * @param cfg_ configuration
+ */
+static void
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg_)
+{
+ static struct GNUNET_CADET_MessageHandler handlers[] = {
+ {&receive_icmp_service, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE, 0},
+ {&receive_icmp_remote, GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_INTERNET, 0},
+ {&receive_udp_service, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_SERVICE, 0},
+ {&receive_udp_remote, GNUNET_MESSAGE_TYPE_VPN_UDP_TO_INTERNET, 0},
+ {&receive_tcp_service, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START, 0},
+ {&receive_tcp_remote, GNUNET_MESSAGE_TYPE_VPN_TCP_TO_INTERNET_START, 0},
+ {&receive_tcp_data, GNUNET_MESSAGE_TYPE_VPN_TCP_DATA_TO_EXIT, 0},
+ {&receive_dns_request, GNUNET_MESSAGE_TYPE_VPN_DNS_TO_INTERNET, 0},
+ {NULL, 0, 0}
+ };
+ struct GNUNET_HashCode port;
+ char *policy;
+ char *binary;
+ char *regex;
+ char *prefixed_regex;
+
+ cfg = cfg_;
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg,
+ "exit",
+ "MAX_CONNECTIONS",
+ &max_connections))
+ max_connections = 1024;
+ parse_ip_options ();
+ if ( (ipv4_exit) || (ipv6_exit) )
+ {
+ binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit");
+ if (GNUNET_YES !=
+ GNUNET_OS_check_helper_binary (binary,
+ GNUNET_YES,
+ "-d gnunet-vpn - - - 169.1.3.3.7 255.255.255.0")) //no nat, ipv4 only
+ {
+ GNUNET_free (binary);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("`%s' must be installed SUID, EXIT will not work\n"),
+ "gnunet-helper-exit");
+ GNUNET_SCHEDULER_add_shutdown (&dummy_task,
+ NULL);
+ global_ret = 1;
+ return;
+ }
+ GNUNET_free (binary);
+ }
+ if (! (ipv4_enabled || ipv6_enabled))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("No useful service enabled. Exiting.\n"));
GNUNET_SCHEDULER_shutdown ();
return;
}
- cadet_handle = GNUNET_CADET_connect (cfg, NULL, &clean_channel, handlers);
+
+ GNUNET_SCHEDULER_add_shutdown (&cleanup,
+ NULL);
+ stats = GNUNET_STATISTICS_create ("exit",
+ cfg);
+ cadet_handle = GNUNET_CADET_connect (cfg,
+ NULL,
+ &clean_channel,
+ handlers);
if (NULL == cadet_handle)
{
GNUNET_SCHEDULER_shutdown ();
return;
}
- for (int i = 0;
- GNUNET_APPLICATION_TYPE_END != apptypes[i]
- && i < sizeof (apptypes)/sizeof (*apptypes);
- i++)
+ advertise_dns_exit ();
+ if (GNUNET_OK !=
+ setup_exit_helper_args ())
{
- GNUNET_CADET_open_port (cadet_handle, GC_u2h (apptypes[i]),
- &new_channel, NULL);
+ GNUNET_SCHEDULER_shutdown ();
+ return;
}
- /* Cadet handle acquired, now announce regular expressions matching our exit */
+ udp_services = GNUNET_CONTAINER_multihashmap_create (65536,
+ GNUNET_NO);
+ tcp_services = GNUNET_CONTAINER_multihashmap_create (65536,
+ GNUNET_NO);
+ connections_map = GNUNET_CONTAINER_multihashmap_create (65536,
+ GNUNET_NO);
+ connections_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
+ GNUNET_CONFIGURATION_iterate_sections (cfg,
+ &read_service_conf,
+ NULL);
+
+ /* Cadet handle acquired, now open ports and announce regular
+ expressions matching our exit */
if ( (GNUNET_YES == ipv4_enabled) && (GNUNET_YES == ipv4_exit) )
{
+ GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_IPV4_GATEWAY,
+ strlen (GNUNET_APPLICATION_PORT_IPV4_GATEWAY),
+ &port);
+ GNUNET_CADET_open_port (cadet_handle,
+ &port,
+ &new_channel,
+ NULL);
policy = NULL;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
}
}
- if (GNUNET_YES == ipv6_enabled && GNUNET_YES == ipv6_exit)
+ if ( (GNUNET_YES == ipv6_enabled) && (GNUNET_YES == ipv6_exit) )
{
+ GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_IPV6_GATEWAY,
+ strlen (GNUNET_APPLICATION_PORT_IPV6_GATEWAY),
+ &port);
+ GNUNET_CADET_open_port (cadet_handle,
+ &port,
+ &new_channel,
+ NULL);
policy = NULL;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
/*
This file is part of GNUnet.
- Copyright (C) 2011 GNUnet e.V.
+ Copyright (C) 2011, 2016 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
#define GNUNET_APPLICATION_TYPE_TEST 1
/**
- * Internet DNS resolution (external DNS gateway).
+ * Transfer of blocks for non-anonymmous file-sharing.
*/
-#define GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER 2
+#define GNUNET_APPLICATION_TYPE_FS_BLOCK_TRANSFER 3
/**
- * Transfer of blocks for non-anonymmous file-sharing.
+ * Internet DNS resolution (external DNS gateway). This is a "well-known"
+ * service a peer may offer over CADET where the port is the hash of this
+ * string.
*/
-#define GNUNET_APPLICATION_TYPE_FS_BLOCK_TRANSFER 3
+#define GNUNET_APPLICATION_PORT_INTERNET_RESOLVER "exit-dns"
/**
* Internet IPv4 gateway (any TCP/UDP/ICMP).
*/
-#define GNUNET_APPLICATION_TYPE_IPV4_GATEWAY 16
+#define GNUNET_APPLICATION_PORT_IPV4_GATEWAY "exit-ipv4"
/**
* Internet IPv6 gateway (any TCP/UDP/ICMP).
*/
-#define GNUNET_APPLICATION_TYPE_IPV6_GATEWAY 17
+#define GNUNET_APPLICATION_PORT_IPV6_GATEWAY "exit-ipv6"
/**
- * Internet exit regex prefix. Consisting of application ID, followed by version
- * and padding.
+ * Internet exit regex prefix. Consisting of application ID, followed
+ * by version and padding.
*/
#define GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX "GNUNET-VPN-VER-0001-"
/**
* Consensus.
+ *
+ * @deprecated
*/
#define GNUNET_APPLICATION_TYPE_CONSENSUS 18
/**
* Set. Used for two-peer set operations implemented using stream.
+ * @deprecated
*/
#define GNUNET_APPLICATION_TYPE_SET 19
-/**
- * Vectorproduct. Used for two-peer scalarproduct operations
- */
-#define GNUNET_APPLICATION_TYPE_SCALARPRODUCT 20
-
/**
* Conversation control data.
+ * @deprecated
*/
#define GNUNET_APPLICATION_TYPE_CONVERSATION_CONTROL 21
/**
* Conversation audio data.
+ * @deprecated
*/
#define GNUNET_APPLICATION_TYPE_CONVERSATION_AUDIO 22
/**
* MQTT publish-subscribe.
+ * @deprecated
*/
#define GNUNET_APPLICATION_TYPE_MQTT 23
-/**
- * Application receiving sensor measurements from peers
- */
-#define GNUNET_APPLICATION_TYPE_SENSORDASHBOARD 24
-
-/**
- * Application offering sensor updates
- */
-#define GNUNET_APPLICATION_TYPE_SENSORUPDATE 25
-
/**
* Multicast data.
+ * @deprecated
*/
#define GNUNET_APPLICATION_TYPE_MULTICAST 26
-/**
- * Vectorproduct, ECC variant. Used for two-peer scalarproduct operations
- */
-#define GNUNET_APPLICATION_TYPE_SCALARPRODUCT_ECC 27
#if 0 /* keep Emacsens' auto-indent happy */
{
*/
#define GNUNET_memcpy(dst,src,n) do { if (0 != n) { (void) memcpy (dst,src,n); } } while (0)
+
/**
* @ingroup memory
* Allocate a size @a n array with structs or unions of the given @a type.
struct CadetExit *pos;
uint32_t candidate_count;
uint32_t candidate_selected;
+ struct GNUNET_HashCode port;
+ GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_INTERNET_RESOLVER,
+ strlen (GNUNET_APPLICATION_PORT_INTERNET_RESOLVER),
+ &port);
candidate_count = 0;
for (pos = exit_head; NULL != pos; pos = pos->next)
if (NULL == pos->cadet_channel)
if (candidate_selected < candidate_count)
{
/* move to the head of the DLL */
- pos->cadet_channel = GNUNET_CADET_channel_create (cadet_handle,
- pos,
- &pos->peer,
- GC_u2h (GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER),
- GNUNET_CADET_OPTION_DEFAULT);
+ pos->cadet_channel
+ = GNUNET_CADET_channel_create (cadet_handle,
+ pos,
+ &pos->peer,
+ &port,
+ GNUNET_CADET_OPTION_DEFAULT);
if (NULL == pos->cadet_channel)
{
GNUNET_break (0);
gettext_noop ("# DNS requests mapped to VPN"),
1, GNUNET_NO);
GNUNET_DNS_request_answer (rc->rh,
- buf_len, buf);
+ buf_len,
+ buf);
GNUNET_free (buf);
}
GNUNET_DNSPARSER_free_packet (rc->dns);
}
GNUNET_STATISTICS_update (stats,
gettext_noop ("# DNS records modified"),
- 1, GNUNET_NO);
+ 1,
+ GNUNET_NO);
switch (rc->rec->type)
{
case GNUNET_DNSPARSER_TYPE_A:
GNUNET_assert (AF_INET == af);
- GNUNET_memcpy (rc->rec->data.raw.data, address, sizeof (struct in_addr));
+ GNUNET_memcpy (rc->rec->data.raw.data,
+ address,
+ sizeof (struct in_addr));
break;
case GNUNET_DNSPARSER_TYPE_AAAA:
GNUNET_assert (AF_INET6 == af);
- GNUNET_memcpy (rc->rec->data.raw.data, address, sizeof (struct in6_addr));
+ GNUNET_memcpy (rc->rec->data.raw.data,
+ address,
+ sizeof (struct in6_addr));
break;
default:
GNUNET_assert (0);
}
rc->rec = rec;
rc->rr = GNUNET_VPN_redirect_to_ip (vpn_handle,
- af, af,
+ af,
+ af,
rec->data.raw.data,
GNUNET_TIME_relative_to_absolute (TIMEOUT),
&vpn_allocation_callback,
if (ipv4_pt)
{
rc->offset = i + 1;
- modify_address (rc, &ra[i]);
+ modify_address (rc,
+ &ra[i]);
return;
}
break;
if (ipv6_pt)
{
rc->offset = i + 1;
- modify_address (rc, &ra[i]);
+ modify_address (rc,
+ &ra[i]);
return;
}
break;
GNUNET_STATISTICS_update (stats,
gettext_noop ("# DNS replies intercepted"),
1, GNUNET_NO);
- dns = GNUNET_DNSPARSER_parse (request, request_length);
+ dns = GNUNET_DNSPARSER_parse (request,
+ request_length);
if (NULL == dns)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
return;
}
work = GNUNET_NO;
- work |= work_test (dns->answers, dns->num_answers);
- work |= work_test (dns->authority_records, dns->num_authority_records);
- work |= work_test (dns->additional_records, dns->num_additional_records);
+ work |= work_test (dns->answers,
+ dns->num_answers);
+ work |= work_test (dns->authority_records,
+ dns->num_authority_records);
+ work |= work_test (dns->additional_records,
+ dns->num_additional_records);
if (! work)
{
GNUNET_DNS_request_forward (rh);
mlen = rc->mlen;
if (mlen > size)
{
- exit->cadet_th = GNUNET_CADET_notify_transmit_ready (exit->cadet_channel,
- GNUNET_NO,
- TIMEOUT,
- mlen,
- &transmit_dns_request_to_cadet,
- exit);
+ exit->cadet_th
+ = GNUNET_CADET_notify_transmit_ready (exit->cadet_channel,
+ GNUNET_NO,
+ TIMEOUT,
+ mlen,
+ &transmit_dns_request_to_cadet,
+ exit);
return 0;
}
GNUNET_assert (GNUNET_NO == rc->was_transmitted);
- GNUNET_memcpy (buf, rc->cadet_message, mlen);
+ GNUNET_memcpy (buf,
+ rc->cadet_message,
+ mlen);
GNUNET_CONTAINER_DLL_remove (exit->transmit_queue_head,
exit->transmit_queue_tail,
rc);
}
GNUNET_STATISTICS_update (stats,
gettext_noop ("# DNS requests dropped (timeout)"),
- 1, GNUNET_NO);
+ 1,
+ GNUNET_NO);
GNUNET_DNS_request_drop (rc->rh);
GNUNET_free (rc);
if ( (0 == get_channel_weight (exit)) &&
}
if ( (NULL == alt->cadet_th) &&
(NULL != (rc = alt->transmit_queue_head)) )
- alt->cadet_th = GNUNET_CADET_notify_transmit_ready (alt->cadet_channel,
- GNUNET_NO,
- TIMEOUT,
- rc->mlen,
- &transmit_dns_request_to_cadet,
- alt);
+ alt->cadet_th
+ = GNUNET_CADET_notify_transmit_ready (alt->cadet_channel,
+ GNUNET_NO,
+ TIMEOUT,
+ rc->mlen,
+ &transmit_dns_request_to_cadet,
+ alt);
}
struct GNUNET_HashCode dns_key;
cfg = cfg_;
- stats = GNUNET_STATISTICS_create ("pt", cfg);
- ipv4_pt = GNUNET_CONFIGURATION_get_value_yesno (cfg, "pt", "TUNNEL_IPV4");
- ipv6_pt = GNUNET_CONFIGURATION_get_value_yesno (cfg, "pt", "TUNNEL_IPV6");
- dns_channel = GNUNET_CONFIGURATION_get_value_yesno (cfg, "pt", "TUNNEL_DNS");
+ stats = GNUNET_STATISTICS_create ("pt",
+ cfg);
+ ipv4_pt = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+ "pt",
+ "TUNNEL_IPV4");
+ ipv6_pt = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+ "pt",
+ "TUNNEL_IPV6");
+ dns_channel = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+ "pt",
+ "TUNNEL_DNS");
if (! (ipv4_pt || ipv6_pt || dns_channel))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
dns_post_handle
= GNUNET_DNS_connect (cfg,
GNUNET_DNS_FLAG_POST_RESOLUTION,
- &dns_post_request_handler, NULL);
+ &dns_post_request_handler,
+ NULL);
if (NULL == dns_post_handle)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
dns_pre_handle
= GNUNET_DNS_connect (cfg,
GNUNET_DNS_FLAG_PRE_RESOLUTION,
- &dns_pre_request_handler, NULL);
+ &dns_pre_request_handler,
+ NULL);
if (NULL == dns_pre_handle)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
GNUNET_SCHEDULER_shutdown ();
return;
}
- cadet_handle = GNUNET_CADET_connect (cfg, NULL,
- &cadet_channel_end_cb,
- cadet_handlers);
+ cadet_handle = GNUNET_CADET_connect (cfg,
+ NULL,
+ &cadet_channel_end_cb,
+ cadet_handlers);
if (NULL == cadet_handle)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
GNUNET_SCHEDULER_shutdown ();
return;
}
- GNUNET_CRYPTO_hash ("dns", strlen ("dns"), &dns_key);
+ GNUNET_CRYPTO_hash ("dns",
+ strlen ("dns"),
+ &dns_key);
dht_get = GNUNET_DHT_get_start (dht,
GNUNET_BLOCK_TYPE_DNS,
&dns_key,
1,
GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
NULL, 0,
- &handle_dht_result, NULL);
+ &handle_dht_result,
+ NULL);
}
}
* @return 0 ok, 1 on error
*/
int
-main (int argc, char *const *argv)
+main (int argc,
+ char *const *argv)
{
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END
};
int ret;
- if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
+ if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc,
+ argv,
+ &argc,
+ &argv))
return 2;
ret = (GNUNET_OK ==
- GNUNET_PROGRAM_run (argc, argv, "gnunet-daemon-pt",
- gettext_noop
- ("Daemon to run to perform IP protocol translation to GNUnet"),
- options, &run, NULL)) ? 0 : 1;
+ GNUNET_PROGRAM_run (argc,
+ argv,
+ "gnunet-daemon-pt",
+ gettext_noop ("Daemon to run to perform IP protocol translation to GNUnet"),
+ options,
+ &run,
+ NULL))
+ ? 0
+ : 1;
GNUNET_free ((void*) argv);
return ret;
}
* @param message the actual message
*/
void
-GST_handle_barrier_status (void *cls, struct GNUNET_SERVER_Client *client,
+GST_handle_barrier_status (void *cls,
+ struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct GNUNET_TESTBED_BarrierStatusMsg *msg;
* @return #GNUNET_YES on success
*/
int
-GNUNET_CRYPTO_kdf_v (void *result, size_t out_len,
- const void *xts, size_t xts_len,
- const void *skm, size_t skm_len,
+GNUNET_CRYPTO_kdf_v (void *result,
+ size_t out_len,
+ const void *xts,
+ size_t xts_len,
+ const void *skm,
+ size_t skm_len,
va_list argp)
{
/*
* http://eprint.iacr.org/2010/264
*/
- return GNUNET_CRYPTO_hkdf_v (result, out_len, GCRY_MD_SHA512, GCRY_MD_SHA256,
- xts, xts_len, skm, skm_len, argp);
+ return GNUNET_CRYPTO_hkdf_v (result,
+ out_len,
+ GCRY_MD_SHA512,
+ GCRY_MD_SHA256,
+ xts,
+ xts_len,
+ skm,
+ skm_len,
+ argp);
}
* @return #GNUNET_YES on success
*/
int
-GNUNET_CRYPTO_kdf (void *result, size_t out_len,
- const void *xts, size_t xts_len,
- const void *skm, size_t skm_len, ...)
+GNUNET_CRYPTO_kdf (void *result,
+ size_t out_len,
+ const void *xts,
+ size_t xts_len,
+ const void *skm,
+ size_t skm_len, ...)
{
va_list argp;
int ret;
va_start (argp, skm_len);
- ret = GNUNET_CRYPTO_kdf_v (result, out_len, xts, xts_len, skm, skm_len, argp);
+ ret = GNUNET_CRYPTO_kdf_v (result,
+ out_len,
+ xts,
+ xts_len,
+ skm,
+ skm_len,
+ argp);
va_end (argp);
return ret;
gcry_mpi_release (*r);
}
}
+
+/* end of crypto_kdf.c */
ret = tnq->len;
GNUNET_free (tnq);
if (NULL != (tnq = ts->tmq_head))
- ts->th = GNUNET_CADET_notify_transmit_ready (ts->channel,
- GNUNET_NO /* cork */,
- GNUNET_TIME_UNIT_FOREVER_REL,
- tnq->len,
- &send_to_peer_notify_callback,
- ts);
+ {
+ if (NULL == ts->th)
+ ts->th = GNUNET_CADET_notify_transmit_ready (ts->channel,
+ GNUNET_NO /* cork */,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ tnq->len,
+ &send_to_peer_notify_callback,
+ ts);
+ }
GNUNET_STATISTICS_update (stats,
gettext_noop ("# Bytes given to cadet for transmission"),
ret, GNUNET_NO);
unsigned int put_path_length)
{
struct ChannelState *ts = cls;
- unsigned int apptype;
+ struct GNUNET_HashCode port;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Exit %s found for destination %s!\n",
switch (ts->af)
{
case AF_INET:
- apptype = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY;
+ /* these must match the strings used in gnunet-daemon-exit */
+ GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_IPV4_GATEWAY,
+ strlen (GNUNET_APPLICATION_PORT_IPV4_GATEWAY),
+ &port);
break;
case AF_INET6:
- apptype = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY;
+ /* these must match the strings used in gnunet-daemon-exit */
+ GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_IPV6_GATEWAY,
+ strlen (GNUNET_APPLICATION_PORT_IPV6_GATEWAY),
+ &port);
break;
default:
GNUNET_break (0);
ts->channel = GNUNET_CADET_channel_create (cadet_handle,
ts,
id,
- GC_u2h (apptype),
+ &port,
GNUNET_CADET_OPTION_DEFAULT);
}
int client_af)
{
struct ChannelState *ts;
- unsigned int apptype;
GNUNET_STATISTICS_update (stats,
gettext_noop ("# Cadet channels created"),
- 1, GNUNET_NO);
- switch (client_af)
- {
- case AF_INET:
- apptype = GNUNET_APPLICATION_TYPE_IPV4_GATEWAY;
- break;
- case AF_INET6:
- apptype = GNUNET_APPLICATION_TYPE_IPV6_GATEWAY;
- break;
- default:
- GNUNET_break (0);
- return NULL;
- }
+ 1,
+ GNUNET_NO);
ts = GNUNET_new (struct ChannelState);
ts->af = client_af;
ts->destination = *dt->destination;
ts->channel = GNUNET_CADET_channel_create (cadet_handle,
ts,
&dt->destination->details.service_destination.target,
- GC_u2h (apptype),
+ &ts->destination.details.service_destination.service_descriptor,
GNUNET_CADET_OPTION_DEFAULT);
if (NULL == ts->channel)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Failed to setup cadet channel!\n"));
+ GNUNET_break (0);
GNUNET_free (ts);
return NULL;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Routing %s packet from [%s]:%u -> [%s]:%u to destination [%s]:%u\n",
(protocol == IPPROTO_TCP) ? "TCP" : "UDP",
- inet_ntop (af, source_ip, sbuf, sizeof (sbuf)),
+ inet_ntop (af,
+ source_ip,
+ sbuf,
+ sizeof (sbuf)),
source_port,
- inet_ntop (af, destination_ip, dbuf, sizeof (dbuf)),
+ inet_ntop (af,
+ destination_ip,
+ dbuf,
+ sizeof (dbuf)),
destination_port,
inet_ntop (destination->details.exit_destination.af,
&destination->details.exit_destination.ip,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Routing %s packet from [%s]:%u -> [%s]:%u to service %s at peer %s\n",
(protocol == IPPROTO_TCP) ? "TCP" : "UDP",
- inet_ntop (af, source_ip, sbuf, sizeof (sbuf)),
+ inet_ntop (af,
+ source_ip,
+ sbuf,
+ sizeof (sbuf)),
source_port,
- inet_ntop (af, destination_ip, dbuf, sizeof (dbuf)),
+ inet_ntop (af,
+ destination_ip,
+ dbuf,
+ sizeof (dbuf)),
destination_port,
GNUNET_h2s (&destination->details.service_destination.service_descriptor),
GNUNET_i2s (&destination->details.service_destination.target));
usm->destination_port = udp->destination_port;
usm->service_descriptor = destination->details.service_destination.service_descriptor;
GNUNET_memcpy (&usm[1],
- &udp[1],
- payload_length - sizeof (struct GNUNET_TUN_UdpHeader));
+ &udp[1],
+ payload_length - sizeof (struct GNUNET_TUN_UdpHeader));
}
else
{
tsm->service_descriptor = destination->details.service_destination.service_descriptor;
tsm->tcp_header = *tcp;
GNUNET_memcpy (&tsm[1],
- &tcp[1],
- payload_length - sizeof (struct GNUNET_TUN_TcpHeader));
+ &tcp[1],
+ payload_length - sizeof (struct GNUNET_TUN_TcpHeader));
}
else
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Allocated address %s for redirection to service %s on peer %s\n",
- inet_ntop (result_af, addr, sbuf, sizeof (sbuf)),
+ inet_ntop (result_af,
+ addr,
+ sbuf,
+ sizeof (sbuf)),
GNUNET_h2s (&msg->service_descriptor),
GNUNET_i2s (&msg->target));
}
rip->addr_af = htonl (rr->addr_af);
rip->request_id = rr->request_id = ++vh->request_id_gen;
GNUNET_memcpy (&rip[1],
- rr->addr,
- alen);
+ rr->addr,
+ alen);
}
GNUNET_MQ_send (vh->mq,
env);